My requirement is I want to connect to a table in the data base and retrive the column of data for a particula condition. ex: Select TxnId from Table t where t.bachNo = x;
here TxnId is a column name of the table. It retrives 120 records(Imagine)
Now I have to store these values into an ArrayList .
Please give me the solution. I am very much Thank full to you .
Deepa
Rusty Shackleford
Ranch Hand
Joined: Jan 03, 2006
Posts: 490
posted
0
OK, I will give you the solution for the bargain price of $1,000,000 US.
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
OK, what is the problem?
1. connecting to the database 2. retrieving the records 3. adding them to an Arraylist 4. other 5. all of the above
Deepa Sindhu
Greenhorn
Joined: Aug 24, 2006
Posts: 2
posted
0
Originally posted by Michael Dunn: OK, what is the problem?
1. connecting to the database 2. retrieving the records 3. adding them to an Arraylist 4. other 5. all of the above
After getting the column data I have to add those data into ArrayList . Please help me.
Deepa
Felx Devasia
Greenhorn
Joined: Aug 13, 2006
Posts: 2
posted
0
I guess you are currently holding data in a resultset(say, rs). For populating arrayList, you need to loop loop thru the resultset. eg: ArrayList resultHolder=new ArrayList(); if(rs!=null){ while(rs.next){ resultHolder.add(rs.getString(1));//gets first element from resultset } } I personally advice you to look more into JDBC and collections framework. Sun provides excellent tutorials for both.