Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Releasing JavaBean resources  RSS feed

 
Nigel King
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a javabean defined as a session bean.
Is it good practice to release the resources in that bean once the session is ended? And, if so, how do I go about doing that? Or does the garbage collector take care of it?
The reason I ask is that my bean holds a CachedRowSetImpl and I'd like to close this and be sure the database connection is closing when the session ends.

Thanks in advance.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a class that implements HttpSessionListener interface and in the sessionDestroyed() method which is guaranteed to be called before session expiry, you can do the cleanup act.

I wonder if holding the data from the result set as a model object isnt a cleaner solution.

ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!