| Author |
storing Resultset in a collection
|
surendar prabu
Ranch Hand
Joined: Jul 24, 2006
Posts: 102
|
|
I need to store my resultset in a collection object.is there any direct method available for this? or should i explicitly type cast result set to a collection? regards, surendar
|
SCJP 1.4
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
No to both questions. What you should do is this: read each row of the ResultSet; convert that row to an object of some class that is suitable to your program's requirements; add that object to a collection.
|
 |
Chetan Natu
Greenhorn
Joined: Dec 03, 2005
Posts: 19
|
|
|
Don't forget to read the resultsetmetadata to extract the field name, size, type etc.,etc., Which will be handy if you want to generate a generalised code to work with any database
|
Never Remember the failure
Never Forget the mistake
|
 |
Rajah Nagur
Ranch Hand
Joined: Nov 06, 2002
Posts: 239
|
|
Originally posted by surendar prabu: I need to store my resultset in a collection object.is there any direct method available for this? or should i explicitly type cast result set to a collection? regards, surendar
I think what you need is disconnected rowset. Rowset extends ResultSet. You can definitely keep this Rowset in any collection object. There is no need to typecast while storing, but while retrieving you need to downcast. This is what I understand from your question...hope it helps. [ August 09, 2006: Message edited by: Rajah Nagur ]
|
You can't wake a person who is <b><i>pretending</i></b> to be asleep.<br />Like what <b>"it"</b> does not like - <i> Gurdjieff </i>
|
 |
Joshy Thomas
Greenhorn
Joined: Jul 23, 2004
Posts: 13
|
|
If you can try using the Apache QueryRunner, which is part of the dbutils, jakarta commons project. You can get examples at http://jakarta.apache.org/commons/dbutils/examples.html
|
<a href="http://www.FindTaxService.com" target="_blank" rel="nofollow">Free Tax Software</a>
|
 |
dhoom dhoomm
Greenhorn
Joined: Sep 05, 2012
Posts: 2
|
|
I have created a class for my project, i hope it might be useful for you..
Also make sure, the rows fetched are limited or it may eat up your memory..
Also, i am open to suggestions...
|
 |
 |
|
|
subject: storing Resultset in a collection
|
|
|