commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joachim Schuler" <>
Subject [DBCP] Problems with SQLWarnings chained to Connections in the pool
Date Thu, 19 Jun 2003 13:31:49 GMT
Hi all,

we have recently migrated a web application from using poolman to dbcp. The
db driver used for this application is jconnect.

During some long-term tests, we observed a memory-leak like behaviour,
caused by a growing number of objects on the heap which could not be garbage
collected. After some investigation we found out that the memory is consumed
by SQLWarnings, chained to connections in the pool. The SQLWarnings are
generated when calling setReadOnly() on the underlying Connection (which is
done regularly when taking an object from the pool), and they never get

We feel the application should not have to worry about that, but instead the
pool should provide a Connection without any "old" SQLWarnings attached to
it. We have therefore introduced a patch into DBCP. A modified version of
PoolableConnectionFactory.passivateObject(Object obj) that is clearing the
old SQLWarnings when returning a connection to the pool might look like

public void passivateObject(Object obj) throws Exception {
    if(obj instanceof Connection) {
        Connection conn = (Connection)obj;
        if(!conn.getAutoCommit()) {
        try {
        } catch(Exception e) {}

    if(obj instanceof DelegatingConnection) {

We would be glad to see this or a similar solution incorporated into the
DBCP source tree.

Best regards,
- Joachim

Joachim Schuler, epecon GmbH, Ost-West-Strasse 63, D-20147 Hamburg
Tel. +49 40 300 697-38, Mobil: +49 171 875 8020, Fax +49 40 300 697 31

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message