• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

storing Resultset in a collection

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic