commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Austin Mills" <>
Subject DBCP: Question about throwing an exception when Connection.close() is called twice
Date Fri, 10 Sep 2004 19:17:45 GMT
Hello all,

I just started using DBCP and am pretty happy with it, but I've come across something that
seems a bit strange to me. When a
connection received from the DBCP pool has close() called upon it two times, on the second
call, it will throw an SQL exception such

java.sql.SQLException: Connection is closed.
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(
at... (my code from here on)

After browsing the docs/archives, this seems to be intended as a feature (or at a fix to a
previous bug, ) and I can understand that, as it's
generally indicative
of poor logic to close a connection twice. This is, however, directly in contradiction of
the interface java.sql.Connection, which
states in the javadocs of the close() method:

"Calling the method close on a Connection object that is already closed is a no-op."

Functionally, what this means is that when a developer has an existing codebase where connections
are double-closed (bad, yes, but
within the interface definition), he can switch to the DBCP pooling system from another system
and end up having exceptions thrown
from double-closing Connections (as I did). 

My question is, is this a conscious decision on the part of the developers to break away from
that point in the interface
definition? Or is it just something that was overlooked in the interests of writing better

My hunch is that I should write this up as a bug in Bugzilla, but I wanted to get the opinions
of the developers.

Austin Mills
SensorLogic | M2M made easy.
972-934-7375 x2107
972-934-7376 (fax)

Join SensorLogic at Wireless Sensing Solutions 2004 and receive a 25% discount on the conference
program when you register online at with SensorLogic priority code:  B0104. 

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

View raw message