title: Searching data in database using JSP
body: <p>What is the problem with the following code? I want to search data in the database using the following JSP code. </p>
  
  <p>search.jsp</p>
  
  <pre><code>&lt;%@ page import="java.sql.*" %&gt;
  &lt;html&gt;
  &lt;form&gt;
  &lt;table&gt;
  &lt;%
  String value=request.getParameter("id");
  int v=Integer.parseInt(value);
  Class.forName("com.mysql.jdbc.Driver");
  Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee ","root", "root");
  Statement st=conn.createStatement();
  ResultSet rs = st.executeQuery("select * from test where id="+v+"");
  if(rs.next()){ 
      %&gt;
  &lt;tr&gt;&lt;td&gt;Name: &lt;/td&gt;&lt;td&lt;input type="text" value="&lt;%=rs.getString("name")%&gt;" &gt; &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Address: &lt;/td&gt;&lt;td&lt;input type="text" value="&lt;%=rs.getString("address")%&gt;" &gt; &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Contact No: &lt;/td&gt;&lt;td&lt;input type="text" value="&lt;%=rs.getInt("contactNo")%&gt;" &gt; &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Email: &lt;/td&gt;&lt;td&lt;input type="text" value="&lt;%=rs.getString("email")%&gt;" &gt; &lt;/td&gt;&lt;/tr&gt;
        &lt;%
  }
  %&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>