my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes ResultSet --> ArrayList or Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ResultSet --> ArrayList or Vector" Watch "ResultSet --> ArrayList or Vector" New topic

ResultSet --> ArrayList or Vector

Naveen Asha

Joined: Mar 30, 2003
Posts: 12
How we can convert a resultset in a collection framework e.g. ArrayList or Vector?
Thank you,
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

I am moving your post to the JDBC forum since it doesn't deal with any GUI issues...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

ArrayList is the Collection of choice. If you need to synchronize the list, use the Collections utilities instead of using a Vector. Vectors are outdated and shouldn't really be used when writing new code.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Take a look at a recent Intermediate Forum thread on this topic.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Matthew Payne

Joined: May 12, 2003
Posts: 4
RowSetDynaClass could help
import org.apache.commons.beanutils.RowSetDynaClass;
then --->
rs = pstmt.executeQuery();
RowSetDynaClass rsdc = new RowSetDynaClass(rs);
rows = rsdc.getRows();
List rows = rsdc.getRows();
I agree. Here's the link:
subject: ResultSet --> ArrayList or Vector
It's not a secret anymore!