Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing Database Connections  RSS feed

 
Aleksey Matiychenko
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the setup. We have an application running on Weblogic 6.1. We use a stateful session bean to perform dynamic SQL queries on the database. The bean is stateful because we need to provide paging functionality for a client and therefore need to know client's state. We keep user resultset in the bean and provide methods for accessing them a small number of rows at a time.
We keep a handle to the SF bean in our http session so a user can access it later in the application.
Another complexity is that the web app is accessed through another web appapp (a menu web app)
The problem is that we cannot seem to be able to close connections when a user logs out or his session times out.
We tried insatlling session listeners but because of the multiple web apps (I think) we seem to be unable to get to the right http session on logout.
Any ideas?

:roll:
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had this "problem" with WebLogic 6.1 and basically it doesn't close down HTTP sessions when you expect it to. If you have a scan around the documentation, there is a WebLogic API for manually closing the session.
I'll have a quick look now to see if I can dig it out...
Simon
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give something like this a whirl...

Hope that helps
Simon
 
Milind V. Kulkarni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am not very sure whether it is really required to keep the connection open for a 'paging' functionality. In our project we have a similar functionality. We are limiting the size of our result set using "rownum" psedocolumn. Since you are also using a Stateful Bean it would be deinitely possible for you to keep a reference of the last row retrieved and when the next request made you can retrieve another set of results. Now during each SQL query we are flushing the data out of resultset into a corresponding structure and then closing the ResultSet as well as the Connection object.
Important thing here is to remember that when you close the connection the connection is not actually closed but it is return to the pool. Hence you can open or close as many connections without incurring major performance over head.
I think it is very difficult to track whether all the Connections are closed when session is terminated. To achive this you might have to carry all the open Connection objects in your Session object and close them when the session is invalidated.
Regards,
Milind
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!