-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Josh,

On 10/29/2009 9:17 PM, Josh Gooding wrote:
> I wrote some code on top of the Tomcat's ConnectionPool class.  In regular
> Java based programming if I close a ResultSet with connection.close(), this
> frees up both the statement and resultset's memory associated with the
> connection if it was still open.  If I close a connection with Tomcat's
> ConnectionPool, does it also close the statement and resultset's associated
> with that particular connection or do I need to manually close them?

This is a good question that was partially discussed over the past few
days (see the thread "DBCP woes (running out of cursors)." for the whole
sordid mess, but here's a quote from me:

"
Technically speaking, the JDBC specification requires that calling
Connection.close() also close any Statement (and therefore ResultSet)
objects that were opened as well. The lines become blurred a bit when
you're talking about pooled connections, because Connection.close()
doesn't really get called... it's a grey area in the spec if you ask me,
but I'd prefer that a pooled connection act like a non-pooled connection
in this case, but there's no "recycle" or "reset" method in the
java.sql.Connection class, and calling Connection.close() on the actual
connection is not appropriate (since it's pooled) so there may be no way
to actually implement this mimicry.
"

> I know best practice is to not rely on anything to be closed automatically,
> but I inherited a code base and I am looking at making some pretty
> significant changes to fix some problems, and this is one of them.

At the risk of being doubly-self-referential:
http://blog.christopherschultz.net/?p=68

Fortunately, clean JDBC code doesn't need to be all that messy (uh...
right).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrqcmgACgkQ9CaO5/Lv0PBc/QCdHPc6AFdcLPhxYDU6hpL+mFEP
s9gAoJJznfRIoDhFPvm98R8Q9kx6n7Tr
=puM5
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to