File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes connection pool in UDB does not close connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "connection pool in UDB does not close connections" Watch "connection pool in UDB does not close connections" New topic

connection pool in UDB does not close connections

Irene Loos
Ranch Hand

Joined: Apr 15, 2002
Posts: 78
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
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: 78
Thank you, Peter. I will try this out.
I agree. Here's the link:
subject: connection pool in UDB does not close connections
It's not a secret anymore!