A web application has to explicetely close ResultSet's, Statement's, and Connection's. Failure of a web application to close these resources can result in them never being available again for reuse, a db connection pool "leak". This can eventually result in your web application db connections failing if there are no more available connections.
There is a solution to this problem. The Jakarta-Commons DBCP can be configured to track and recover these abandoned dB connections. Not only can it recover them, but also generate a stack trace for the code which opened these resources and never closed them.
To configure a DBCP DataSource so that abandoned dB connections are removed and recycled add the following attribute to the
Resource configuration for your DBCP DataSource:
removeAbandonedTimeout attribute to set the number of seconds a dB connection has been idle before it is considered abandoned.
logAbandoned attribute can be set to
true if you want DBCP to log a stack trace of the code which abandoned the dB connection resources.
logAbandoned="true"The default is
Abstract taken from