aspose file tools*
The moose likes JDBC and the fly likes Regarding CachedRowSet instance tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding CachedRowSet instance tracking" Watch "Regarding CachedRowSet instance tracking" New topic
Author

Regarding CachedRowSet instance tracking

Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi there,
I would like to know when exactly the CachedRowSet is going to be eligible for GC. With a little homework I learned that when the user session ends then it would be qualified for GC. Moreover, how is the user session tracked in such cases. What is the "session" here in this context?
Sample scenarios,
Scn 1: When I directly access CachedRowSet from servlet
Scn 2: When I have a stateless session bean and then a JDBC call

in Scn1- I can somehow get the session reference and hence i could maintain. How about the Scn 2? I would only have user thread Id in this case. So how does it work? Is it going to consider the thread id for tracking the existence of the CachedRowSet?
Do we have any good reference articles and links. Correct me if I am wrong somewhere.

Thank you in advance

Have Fun with Java
little,little.. little by little makes a lot..
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

A CachedRowSet is just like any other java instance variable as far as GC is concerned, the caching only means that you can close the database collection and still have the data (unlike a ResultSet).

Hope that was some help.
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Thank you Gibbons,
It opens lot of gaps to learn that " it would act like instance variable as far GC is concerned". So when I come out of the behavior/operation then, is this data lost? For example, I have a method in DAO which uses CRS when the flow comes out of this class, Is the CRS used eligible for GC? If the answer is yes then it is good else it should be somehow referenced.

Thank you in advance
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

rephrase that question using int instead of cachedRowSet, what would the answer be?

if you no longer have a reference to the DAO, and no longer have a referance to the CRS then it is ready to GC, the data will be lost from memory (it will of course still be on the database).
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Thank you again, I got it, crystal clear. Initially my perspective was like it acts as something like a state full container for the complete session. This makes sense for using it cleverly.
Thank you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Regarding CachedRowSet instance tracking