import java.io.*;
import java.sql.*;
public class JdbcRetrieval
{
ArrayList retrieval(
String COURSE,String YEAR)throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:total","system","oracle");
Statement stmt=con.createStatement();
String query="select SNAME,HTICKETNO from total where COURSE='"+COURSE+"' and YEAR='"+YEAR+"'";
System.out.println(query);
ResultSet res=stmt.executeQuery(query);
// CourseStudents cs1=new CourseStudents();
// ArrayList a1=new ArrayList();
while(res.next())
{
// System.out.println(res.getString(1)+" "+res.getInt(2));
ArrayList al=new ArrayList(new CourseStudents());
cs1.setStuname(res.getString(1));
cs1.setStuno(res.getInt(2));
}
res.close();
stmt.close();
con.close();
return cs1;
}
}
this is my
jdbc program which is called by a
servlet. in this program table records are retrieved correctly. my question is " how can i add the beans(CourseStudents) to an ArrayList for all the records of a table. please help me in this problem.
Thanks in advance.