commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22079] - [DBCP] if connection closed twice *closed* connection is returned from the pool
Date Sat, 09 Aug 2003 19:38:45 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22079>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22079

[DBCP] if connection closed twice *closed* connection is returned from the pool





------- Additional Comments From dirk.verbeeck@pandora.be  2003-08-09 19:38 -------
Original mail from Daniel
--------------------------
If I accidentally close DBCP connections twice, it will eventually cause the
JNDI datasource to start returning connections that are already closed.

Essentially my problem is this:

while (true)
{
  DataSource ds = getDataSourceFromJNDI();
  Connection conn = ds.getConnection();
  PreparedStatement ps = conn.prepareStatement("SELECT * FROM ......");
  ResultSet rs = ps.executeQuery();

  rs.close();
  ps.close();
  conn.close();

  // make the mistake of closing it twice
  conn.close();
}

Eventually getDataSourceFromJNDI() returns me a connection that's already
closed. In fact both it, and it's delegate, have the same object reference
IDs as the connections returned by the previous call.

This only happens if I use the connection to do something, and not if I just
create it and then close it.

I can always just wrap the connection in a proxy and then just not forward
on the close call if it's already been closed, but I figure that someone out
there might want to fix this properly and I can't find where I'm supposed to
commit bugs.

This sort of problem is best described in code, so I'm attaching it below.
It's a simple enough servlet that exposes this problem.

Mime
View raw message