| Author |
connection pool in UDB does not close connections
|
Irene Loos
Ranch Hand
Joined: Apr 15, 2002
Posts: 75
|
|
We are getting connections from the pool and closing them after we done, which releases connections to the pool. But even after the application is closed connection to UDB is still exist. Does anybody experience this? [ May 02, 2003: Message edited by: Irene Loos ]
|
Irene Loos
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
What is this DBHelper thing? If it's a homegrown connection pool then it's not at all unlikely that it doesn't properly clean up on application shutdown -- if this is the case, I'd recommend using one of the many solid open-source pools such as Apache Jakarta DBCP (really, a connection pool these days should offer a DataSource interface, connections should be returned simply by closing them, and the implementation should leverage the driver's pooling support whenever possible). Another possible source of problems is that your database clean-up code is broken. Specifically, if rs.close() throws an exception then the statement won't be closed. If either rs.close() or stmt.close() throws an exception then the connection won't be returned to the pool.The above is a watertight way to ensure that ResultSet and Statement are closed and the connection goes back into the pool. It makes use of the fact that closing a Statement will also close any ResultSet that might be open. A completely unrelated issue that I couldn't help but notice is that you catch Exception (often a bad idea born out of lazyness) and re-throw it as a DAOException (fine) throwing away all stack trace information. That is going to make your debugging life a misery at some point. Why not properly wrap your root exception? If you're using JDK 1.4, use the Exception constructor that takes a Throwable cause. If you're using JDK 1.3 or earlier, write your own Exception root class along the following lines:Hope this helps - Peter
|
 |
Irene Loos
Ranch Hand
Joined: Apr 15, 2002
Posts: 75
|
|
|
Thank you, Peter. I will try this out.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: connection pool in UDB does not close connections
|
|
|