This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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?
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