You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "allen.irwin@smartintegration.com.au" <al...@smartintegration.com.au> on 2009/04/01 03:42:52 UTC

Connection Pooling questions

Hello,

I searched on the mailing list back to 2007 and didn't see the answers I
needed for these DataSource related questions (though I did see similar,
not quite what I needed though).

I'm using Tomcat 5.5, Java 1.5 on Windows XP and have used the excellent
guide: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
for configuring the default data source within Tomcat

I configure it using the suggested /META-INF/context.xml with:
maxActive="30" maxIdle="10"

I assumed that maxActive would limit the total amount of DB
connections that could ever be open at one time (in this case 30).  Yet
from what I see it seems like I am limited to maxActive + maxIdle
connections open (in this case 40).  Is that true?

Also, the default behavior seems to be that the connections never close
within the pool when they are not being used.  I had my Tomcat server sit
there for about an hour idle with no client requests incoming and when I
ran netstat -a I still saw 39 connections open, they only closed when I
killed Tomcat.  Do I have to turn on some kind of cleanup explicitly?

I do close the connections within my program using conn.close(); as the
howto suggests. I thought that when the connections were not used that
they would over time be "really" closed and I would end up with the maxIdle
value
of 10 open connections within my Pool.

thanks! 

--------------------------------------------------------------------
mail2web.com – Enhanced email for the mobile individual based on Microsoft®
Exchange - http://link.mail2web.com/Personal/EnhancedEmail



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


RE: Connection Pooling questions

Posted by Martin Gainty <mg...@hotmail.com>.
the configuration you describe only defines parameters to be passed to the Connection Pool Library..which connection pool library are you using?
are you using Thread starve algorithm? or explicit no-activity-on-connection algorithm?
Most connection pools with close the connection only after statement handles are 
quiesced (explicit close) or starved for activity
?
Martin 
______________________________________________ 
Disclaimer and confidentiality note 
This message is confidential and may be privileged. If you are not the intended recipient, we kindly ask you to  please inform the sender. Any unauthorised dissemination or copying hereof is prohibited. This message serves for information purposes only and shall not have any legally binding effect. Given that e-mails can easily be subject to manipulation, we can not accept any liability for the content provided.






> From: allen.irwin@smartintegration.com.au
> To: users@tomcat.apache.org
> Date: Tue, 31 Mar 2009 21:42:52 -0400
> Subject: Connection Pooling questions
> 
> Hello,
> 
> I searched on the mailing list back to 2007 and didn't see the answers I
> needed for these DataSource related questions (though I did see similar,
> not quite what I needed though).
> 
> I'm using Tomcat 5.5, Java 1.5 on Windows XP and have used the excellent
> guide: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
> for configuring the default data source within Tomcat
> 
> I configure it using the suggested /META-INF/context.xml with:
> maxActive="30" maxIdle="10"
> 
> I assumed that maxActive would limit the total amount of DB
> connections that could ever be open at one time (in this case 30).  Yet
> from what I see it seems like I am limited to maxActive + maxIdle
> connections open (in this case 40).  Is that true?
> 
> Also, the default behavior seems to be that the connections never close
> within the pool when they are not being used.  I had my Tomcat server sit
> there for about an hour idle with no client requests incoming and when I
> ran netstat -a I still saw 39 connections open, they only closed when I
> killed Tomcat.  Do I have to turn on some kind of cleanup explicitly?
> 
> I do close the connections within my program using conn.close(); as the
> howto suggests. I thought that when the connections were not used that
> they would over time be "really" closed and I would end up with the maxIdle
> value
> of 10 open connections within my Pool.
> 
> thanks! 
> 
> --------------------------------------------------------------------
> mail2web.com – Enhanced email for the mobile individual based on Microsoft®
> Exchange - http://link.mail2web.com/Personal/EnhancedEmail
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
Internet Explorer 8 – Get your Hotmail Accelerated.  Download free!
http://clk.atdmt.com/MRT/go/141323790/direct/01/

Re: Connection Pooling questions

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chuck,

On 3/31/2009 10:57 PM, Caldarale, Charles R wrote:
>> From: allen.irwin@smartintegration.com.au
>> Subject: Connection Pooling questions
>>
>> I do close the connections within my program using conn.close();
> 
> The evidence suggests otherwise.  You also need to close result sets
> and statements associated with the connection, and all of the close()
> calls should be in a finally block to insure they always get
> executed.

Agreed. See http://blog.christopherschultz.net/?p=68 for examples.

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

iEYEARECAAYFAknTW6AACgkQ9CaO5/Lv0PA6pwCfTDrXTqCfV94BTNKR6tDZl8Gf
uE8AnRBMm2Iraobvs4NNSnIPzUgcdiov
=xPNW
-----END PGP SIGNATURE-----

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


RE: Connection Pooling questions

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: allen.irwin@smartintegration.com.au
> [mailto:allen.irwin@smartintegration.com.au]
> Subject: Connection Pooling questions
> 
> I configure it using the suggested /META-INF/context.xml with:
> maxActive="30" maxIdle="10"

Post your entire context.xml so we can see the rest of the <Resource> element.  Your settings may conflict with what the database expects, resulting in orphaned connections.

> I assumed that maxActive would limit the total amount of DB
> connections that could ever be open at one time (in this case 30).

That limits the number the pool is managing.  If the pool considers some of them to be abandoned or in error, the number the DB knows about may be higher.

> Yet from what I see it seems like I am limited to maxActive + maxIdle
> connections open (in this case 40).  Is that true?

Don't think so.

> Also, the default behavior seems to be that the connections 
> never close within the pool when they are not being used.

That is the whole point of having a pool.

> I do close the connections within my program using conn.close();

The evidence suggests otherwise.  You also need to close result sets and statements associated with the connection, and all of the close() calls should be in a finally block to insure they always get executed.

> I thought that when the connections were not used that they 
> would over time be "really" closed and I would end up with 
> the maxIdle value of 10 open connections within my Pool.

That usually depends entirely on how your DB is configured; if it has a high timeout value (most do), the connections will persist for a long time.  You can configure a timeout value for the pool to evict idle connections, but that's disabled by default.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Connection Pooling questions

Posted by "Propes, Barry L " <ba...@citi.com>.
 Yes! And also, close out any other connections that may be embedded, like a prepared statement, result set or stored procedure. These will also show that a connection is still opened if not explicitly closed!

-----Original Message-----
From: allen.irwin@smartintegration.com.au [mailto:allen.irwin@smartintegration.com.au] 
Sent: Tuesday, March 31, 2009 8:43 PM
To: users@tomcat.apache.org
Subject: Connection Pooling questions


 Do I have to turn on some kind of cleanup explicitly?

I do close the connections within my program using conn.close(); as the howto suggests. I thought that when the connections were not used that they would over time be "really" closed and I would end up with the maxIdle value of 10 open connections within my Pool.

thanks! 

--------------------------------------------------------------------
mail2web.com - Enhanced email for the mobile individual based on Microsoft(r) Exchange - http://link.mail2web.com/Personal/EnhancedEmail



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


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