aspose file tools*
The moose likes JDBC and the fly likes Where does the ResultSet reside? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Where does the ResultSet reside?" Watch "Where does the ResultSet reside?" New topic
Author

Where does the ResultSet reside?

Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi:
Where does the returned ResultSet reside? After a SQL statement executed and a ResultSet is returned, is it still in the dbms, or it is brought to the application server memory?
If it resides in the memory, why it is gone after the statemet created it is closed?
If it reside on the dbms, how can I bring it to the memory?
thanks


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Hannah,
A regular result set resides in memory on the application server. I think there are some settings where you can get it to only load the first X rows and go back to the database to get more. But by default, it's all in memory.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
Hit Jeanne:
Thanks for your replay. If the ResultSet lives in the application memory, why it is gone when the connection, or the statement created are closed? and how can I bring to the memory a part of the result set?
thanks
Dana Hanna
Ranch Hand

Joined: Feb 28, 2003
Posts: 227
javax.sql.RowSet
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
javax.sql.RowSet interface is not supported by SQL 2000 ..!!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Hannah,
You can loop through the result set and put the rows in your own data structure. An ArrayList is common for this sort of thing.
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi:
I know I can user transfer objects to store my data from the ResultSet, but when the ResultSet is huge, it will takes up a lot of memory. I know there is another solution, is to user RowSet, but I am using SQL2k, and it doesn't support RowSet.
any other suggestions.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31054
    
162

Hanna,
What are you doing with the data after you have it? Is it something you can do while the resultset is open? For example if you are writing to a file, you can do that as you loop through the result set.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Where does the ResultSet reside?