T
teser3
I have a class that fetches a record but dont think I need to use List
object because I am fetching one record and not an array of records.
Please advise the best way to change the below class where I assume I
should use something different instead of List? Maybe HashMap? Not
sure how to do this?
public List getRecords(){
ResultSet rs = null;
Statement stmt = null;
Connection connection = null;
List rows = new ArrayList();
try
{
Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection("jdbc:mysql://
localhost/dbase?user=myname&password=thepassword");
stmt = connection.createStatement();
rs = stmt.executeQuery("SELECT * from user where userid =
10");
while(rs.next()){
RowBean row = new RowBean();
row.setFirstname(rs.getString("firstname"));
row.setLastname( rs.getString("lastname"));
rows.add(row);
.....
object because I am fetching one record and not an array of records.
Please advise the best way to change the below class where I assume I
should use something different instead of List? Maybe HashMap? Not
sure how to do this?
public List getRecords(){
ResultSet rs = null;
Statement stmt = null;
Connection connection = null;
List rows = new ArrayList();
try
{
Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection("jdbc:mysql://
localhost/dbase?user=myname&password=thepassword");
stmt = connection.createStatement();
rs = stmt.executeQuery("SELECT * from user where userid =
10");
while(rs.next()){
RowBean row = new RowBean();
row.setFirstname(rs.getString("firstname"));
row.setLastname( rs.getString("lastname"));
rows.add(row);
.....