• 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

Is there a way of storing a resultset in a variable (not copying into arrays etc.)

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im looking to find a way to store the results of a ResultSet (containing a query) in memory. This query is simply (Select * from tablename) so im looking for something that replicates the functionality of ResultSet but stores the data in memory.

I want to load all my required data from a database into seperate objects each representing a table and then pass these 'tables' through to classes.
Im doing this to keep all the database connections in one class and get it over and done with, the database isnt very big.

in my dreams its something like this

ResultSet rs;
rs = select * from tablename
datasheet = rs.results

this is very important to me im going

thanks for reading!

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're going to have to copy this into something at some point of time, because once you close the connection the ResultSet is no longer valid.
 
kevin allen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do you know what I could copy it into? without using arrays, hashmaps etc. somelike that naturally stores data in the same way?
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i.m.h.o a ResultSet Object is a "virtual cursor" that points to a row. So you canĀ“t really copy the "content" of the ResultSet.
 
kevin allen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I think your right.

ok, ill rephrase

is there anything like a VB dataset control in java?

thanks
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TableModel comes into mind, but a List<Object[]> will be just as good. You can then access an entire row and a single cell as follows:
 
kevin allen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know but my teacher made it clear he doesnt like casting and the columns may be different data types.

thanks for all your help, im guessing it simply isnt there if your not thinking of it

regards and be well,

kevin
 
Armando Flores Ibarra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you want to consider using a JPA implementation like Hibernate. This way you can easily manipulate lists of "table objects".
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum as being specific to database connectivity.
 
Grow a forest with seedballs and this 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