You are misunderstanding unreturnedConnectionTimeout
.
There is no Exception for unreturnedConnectionTimeout
to throw. If set properly, it has an effect only if you have leaked a Connection. Some client has checked out a Connection and failed to check it back in. No Exception has occurred. No client has been affected by this, except indirectly, as now there are fewer Connections available to check out. c3p0 just kills the unreturned Connection. There is no one to notify about that.
If you have clients that are waiting indefinitely for Connections, that sounds like you have a Connection leak that is not getting cleaned up by unreturnedConnectionTimeout
, or more likely, you find it unacceptably long for Connections to wait as long as the timeout that you have set.
The thing that you should do is look at those stack traces that get logged, assuming you have debugUnreturnedConnectionStackTraces
set to true
. These stack traces do not represent Exceptions (even though they may print as "DEBUG" Exceptions) -- but they show you the code path that checked out the Connections that were never returned. Fix that, fix the Connection leak, and all your problems will go away. Look at how the Connection got checked out, find that in your code, and make sure that it's impossible that any Connection so checked out would not be closed in some finally
block, or, much more easily post Java 7, via try-with-resources.