You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Daniel Bray (CAPE)" <da...@capetechnologies.com> on 2003/07/31 19:00:04 UTC
JNDI datasource returning *closed* DBCP connections
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.
from me, daniel.
Re: JNDI datasource returning *closed* DBCP connections
Posted by Dirk Verbeeck <di...@pandora.be>.
Hi Daniel
Your example didn't make it. Can you resend it or attach it to the
bugzilla entry:
http://issues.apache.org/bugzilla/show_bug.cgi?id=22079
Regards
Dirk
Daniel Bray (CAPE) wrote:
>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.
>
>
>
>from me, daniel.
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>