Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding CachedRowSet instance tracking

 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic