commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Bray (CAPE)" <>
Subject JNDI datasource returning *closed* DBCP connections
Date Thu, 31 Jul 2003 17:00:04 GMT
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();


  // make the mistake of closing it twice

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.

from me, daniel.

  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message