title: to retrieve data from database and show it with tha radio buttons with radio botton containing the data value
body: <p>i am building a web based  railway ticket reservation system. I want to retrieve all the required data from the database using while loop but show one of the data i.e train_no with radio button so that i could pass it to the next jsp. but while doing this i am getting an sql exception "data not found" . please help me. 
  following is a part of the code...</p>
  
  <pre><code>    &lt;%@page import="java.sql.*"%&gt;
            &lt;%@page import="javax.servlet.*"%&gt;
            &lt;%@page import="java.io.*"%&gt;
          &lt;%String s3=String.valueOf(request.getAttribute("s2"));
          String d3=String.valueOf(request.getAttribute("d2"));
          String dj3=String.valueOf(request.getAttribute("dj2"));
  
          %&gt;
  
  &lt;%  Connection con;
               PreparedStatement ps,ps1;
               ResultSet rs;
   try{
  String driverName="sun.jdbc.odbc.JdbcOdbcDriver";
  String url="jdbc:odbc:rail";
          String username="root";
          String password="root";
          Class.forName(driverName);
          con=DriverManager.getConnection(url,username,password);
           ps=con.prepareStatement("Select * from train_for where source=? and destination=? and doj=?");
           ps.setString(1,s3);
           ps.setString(2,d3);
           ps.setString(3,dj3);
           rs=ps.executeQuery();
           while(rs.next())
               { %&gt;
               &lt;tr&gt;&lt;td&gt;&lt;input type="radio" value="&lt;%=rs.getString("train_no")%&gt;" name="rad1"&gt;&lt;%=rs.getString("train_no")%&gt;&lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;&lt;%=rs.getString(4)%&gt;&lt;/td&gt;&lt;/tr&gt;
               &lt;tr&gt;&lt;td&gt;&lt;%=rs.getString(5)%&gt;&lt;/td&gt;&lt;/tr&gt;
               &lt;br&gt;&lt;br&gt;
            &lt;%}
           }
   catch(Exception e)
        {
        out.println(e);
        }
               %&gt;
  </code></pre>