Should connection pools release all resources associated with a
Connection when a user calls Connection.close()?
Connection.close() just returns the Connection back to the pool. The
pool that I'm using C3P0 doesn't seem to close any Statement,
PStatement, CStatement, or ResultSets from the Connection.
That doesn't seem right. Are there pools that actually close all
resources but not the Connection itself?
Joe Weinstein - 27 Sep 2005 23:06 GMT
> Should connection pools release all resources associated with a
> Connection when a user calls Connection.close()?
[quoted text clipped - 5 lines]
> That doesn't seem right. Are there pools that actually close all
> resources but not the Connection itself?
Yes there are. BEA's WebLogic pools do, for instance. Yes, your
code should work just like standard JDBC. The JDBC spec says
that closing a connection should automatically close any statement
from the connection, and any statement close should automatically
close any result set.
We actually do some tuneable fancy stuff like transparently
caching PreparedStatements so you can get the benefit of re-use,
but a good pool implementation needs to close subordinate user
objects. Otherwise it can't even guarantee that only one thread
is using a given connection. Eg: a retained statement can be
used to call getConnection()...
Joe Weinstein at BEA
Alfred - 29 Sep 2005 15:19 GMT
> Should connection pools release all resources associated with a
> Connection when a user calls Connection.close()?
It's not important. Every time close ResultSet's and Statement's asap.
Don't rely on unknown implementations, so you will be shure your
resources will be closed.
Good luck