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?
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.
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.