tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "JWM" <>
Subject RE: Tracking Datasource Connection Usage?
Date Sat, 08 Oct 2005 00:17:03 GMT
Brian and others,

Good information.  Thanks.  What happens with result sets if they don't get
closed?  Do they live on forever as memory leaks, or do they get cleaned up
by GC when the object referencing them goes out of scope?  If a result set
is left open, does it prevent the connection from getting successfully



-----Original Message-----
From: Brian Cook [] 
Sent: Friday, October 07, 2005 3:38 PM
To: Tomcat Users List
Subject: Re: Tracking Datasource Connection Usage?

JWM wrote:

Two things you can do here.

    1. Set both "removeAbandoned" and "logAbandoned"  parameters to 
true.  This will reclaim most lost connections.  And log a trace of what 
code called a connection that was never closed.

     2.  Use a finally block to close all of your Resultsets and 
connections.  This will insure they are closed even if your code throws 
an exception.

Example :

    ResultSet rs = null;
    Connection con  = null;
try {
catch(Exception e) {
finally {

>I started getting exceptions saying no connections were available on my
>datasource  (  The pool was definitely large
>to handle the load.  So it appears that I'm not freeing the all the
>connections as I should.  I noticed that I did not have the
>'removeAbandoned' flag set on the Resource tag.  Changing that has
>apparently fixed the out of connections problem.  But I really want to
>up the code and fix it the right way.  I've got the close() statements in
>place.  But obviously, I'm missing some of them somewhere.  Is there any
>process for logging/tracking allocating and freeing connections (and
>thereof.), available connections, etc?  Or are there any methods I can call
>to give me this type of debug info?  What's the recommended way to debug
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Brian Cook
Digital Services Analyst
Print Time Inc.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message