commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glenn Nielsen <>
Subject [DBCP] Connection.close() of already closed connections
Date Sat, 29 Jun 2002 17:00:58 GMT
When DBCP closes a db Connection the object is recyled back into
the pool and made available for reuse.  When being used inside
a threaded container like Tomcat it is possible for the following
to happen:

Thread for Request A gets a db connection
Thread for Request A does some work with the db
Thread for Request A closes the db connection
Thread for Request B gets a db connection
  (the same connection Request A just closed)
Due to a bug (most likely an Exception handling bug),
  Thread for Request A closes the db connection again
Thread for Request B tries to use the db connectin,
  Thread B gets an SQLException "Connection is closed."


Which thread opened a db connection should be tracked.
DelegatingConnection.close() should then ignore the
close request if the currentThread is not the same
Thread which opened the connection.

A separate closeAbandoned() method would be available to allow the code
which removes abandoned connections to force closure of a connection
even though a different thread is requesting it.




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

View raw message