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

Josh,

On 10/30/2009 2:10 PM, Josh Gooding wrote:
> Oh this code BLEEDS resources.  The only semi annoyance is that the methods
> that get RS's are usually returned like:
>         return
> ConnectionPool.getConnection().createStatement().executeQuery(sqlCode);

Woo hoo! That looks like Visual Basic code to me. No wonder you have to
expire your connections pretty much immediately.

> This is not bad, but there is NO PLACE in the code that actively closes all
> of the resources.  Sometimes the code is LUCKY to have a call that is to
> rs.close(); but I am more than positive that there is no statement /
> connection closing going on. The hardest part is that everything is mixed
> into the presentation layer.

Double yay! You've definitely got your work cut out for you.

Here's a possibility: if you know that certain code does this
foolishness, you could wrap the Connection object (and Statement, and
ResultSet) with your own wrappers that may be able to clean up after
themselves. For instance, if you write a ResultSet wrapper such that a
call to "close" also closes the Statement that created it, and also
closes the Connection that created that statement, you may be able to
recover from some of this. You could also wrap the 'next' method and, if
the ResultSet is out of results, call a close there, too. Unfortunately,
if you ever try to issue two queries on a single connection, you'll
shoot yourself in the foot, of course.

> The millis has been changed to 54000 (15 seconds), and I'll
> look up more info about the StatementFinalize and the validationQuery.

Once you start actually fixing all the code to properly clean-up after
itself, you should set logAbandoned="true". That will give you a stack
trace for every connection pool check-out that doesn't have a
corresponding check-in (after 15s). At first, it'll drive you crazy
because all your code will be choking and spitting-out stack traces, but
once you fix some of the major ones, you'll find that one or two leaks
still exist and they're super easy to find if you get a stack trace
showing you exactly where they came from.

> This biggest problem I'm having is that I'm the only coder in a .NET shop
> (they all run IIS and code in .NET only) and no one has experience with TC
> except me.  Honestly if it wasn't for this list and the sun forums, I'd be
> sunk on most things Tomcat / java wise.  This list with the members have
> been an invaluable asset to my learning Tomcat.

Glad to help. Good luck.

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

iEYEARECAAYFAkrrO1EACgkQ9CaO5/Lv0PCwsACgwYH4EFewdTv6q/kSPI2GpWZx
XmMAn0JuYN4XYk8H/XYu4cHJe0IL3qj8
=U0UA
-----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