File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes hung jdbc connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "hung jdbc connections" Watch "hung jdbc connections" New topic
Author

hung jdbc connections

camillo granchelli
Greenhorn

Joined: Jun 12, 2001
Posts: 1
Hi all,
I have a web application (servlets) connecting to Oracle RDBMS through a jdbc layer.
The components are:
-Oracle RDBMS 8.0.6
-Web Server iPlanet 4.1
-jdk1.2.2
-Oracle jdbc thin driver 2.0 (classes12.zip)
-Sun/Solaris 2.6
In this configuration I get a wrong behaviour from the jdbc connections: when the user session goes down (because a timeout) the related jdbc connection remains alive and the servlets does not receive any exception.
Actually, for each user session the servlets instantiate a dedicated jdbc connection (it's necessary for the application logic).
I have not concurrent users on the same JDBC connection.
I closed all connections in my finalize() method and I closed
all ResultSet, Statement,PreparedStatements with close().
But open connections are never seemed to be closed.
The only ways to break the connections are either to restart the web server or to restart the db.
Do someone know how to handle this situation at servlet level? That is:
-why the container does not receive any exception?
-why the istantiated jdbc objects does not get destroyed by GC when the connections goes down?

Thanks a lot.
Regards,
Camillo
------------------
Bjarki Holm
Author
Ranch Hand

Joined: May 25, 2001
Posts: 65
Camillo,
do you mean that you create a connection in the servlet's init() method?

------------------
Bjarki Holm
Author of Professional Java Data


Bjarki Holm
Bhupinder Dhillon
Ranch Hand

Joined: Oct 12, 2000
Posts: 124
You have to create a wrapper class which implements HttpSessionBindingListener and then put the wrapper object in the session. Make sure to implement the valueUnbound method in HttpSessionBindingListener and close the connection in it. Essentially whenever the session is expired it fires off an event which notifies the wrapper class and your valueUnbound method is called.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Where are you implementing a finalize() method? If you are doing this in the servlet there is a real good chance it'll never get called! Servlets must implement the destroy() method to do any cleanup of things like your jdbc connections. Try putting the code there.

------------------
Hope This Helps
Carl Trusiak, SCJP2


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: hung jdbc connections