You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dhiren Bhatia <dh...@gmail.com> on 2010/03/15 18:53:38 UTC

Connection pool stats

I've configured my DB connection pool as follows:

context.xml

<Resource name="jdbc/myserver" auth="Container" type="javax.sql.DataSource"

maxActive="100" maxIdle="30" maxWait="10000" username="xxx"

password="xxx" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://a.b.c:3306/Test" removeAbandoned="true"

removeAbandonedTimeout="60" logAbandoned="true" />


web.xml


<resource-ref>

<description>DB Connection</description>

<res-ref-name>jdbc/myserver</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>


In my code, I use a javax.sql.DataSource object to get connections and call
connection.close() to return connections.


How do I get stats on the connection pool? I would like to check how many
connections are active/idle at any point in time.


Thanks,

Dhiren

RE: Connection pool stats

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Dhiren Bhatia [mailto:dhiren.forums@gmail.com]
> Subject: Connection pool stats
> 
> How do I get stats on the connection pool? I would like to check how
> many connections are active/idle at any point in time.

This may help:
http://lambdaprobe.org/d/index.htm

An example of its display for a data source:
http://lambdaprobe.org/d/screenshots/full/datasources.png

You can also programmatically grab statistics for just about anything in your webapp with this:
http://moskito.anotheria.net/

 - 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 pool stats

Posted by Dhiren Bhatia <dh...@gmail.com>.
Hi Mark,

That won't work because Tomcat creates an instance of
org.apache.tomcat.dbcp.dbcp.BasicDataSource which cannot be cast to
org.apache.commons.dbcp.BasicDataSource.

I need to keep the code generic (to run in other containers), so I can't use
org.apache.tomcat.dbcp.dbcp.BasicDataSource in the code to receive the
object Tomcat creates.

Dhiren

On Mon, Mar 15, 2010 at 11:22 AM, Mark Shifman <ma...@yale.edu>wrote:

> You can cast your datasource object to be a BasicDataSource
> then the javadoc gives you all kinds of things you can get.
> like getNumActive(), getNumIdle() etc
> (for dbcp 1.3)
> http://commons.apache.org/dbcp/api-1.3/index.html
>
>
>
> Dhiren Bhatia wrote:
> > I've configured my DB connection pool as follows:
> >
> > context.xml
> >
> > <Resource name="jdbc/myserver" auth="Container"
> type="javax.sql.DataSource"
> >
> > maxActive="100" maxIdle="30" maxWait="10000" username="xxx"
> >
> > password="xxx" driverClassName="com.mysql.jdbc.Driver"
> >
> > url="jdbc:mysql://a.b.c:3306/Test" removeAbandoned="true"
> >
> > removeAbandonedTimeout="60" logAbandoned="true" />
> >
> >
> > web.xml
> >
> >
> > <resource-ref>
> >
> > <description>DB Connection</description>
> >
> > <res-ref-name>jdbc/myserver</res-ref-name>
> >
> > <res-type>javax.sql.DataSource</res-type>
> >
> > <res-auth>Container</res-auth>
> >
> > </resource-ref>
> >
> >
> > In my code, I use a javax.sql.DataSource object to get connections and
> call
> > connection.close() to return connections.
> >
> >
> > How do I get stats on the connection pool? I would like to check how many
> > connections are active/idle at any point in time.
> >
> >
> > Thanks,
> >
> > Dhiren
> >
>
> --
>  Mark Shifman MD. Ph.D.
>  Yale Center for Medical Informatics
>  Phone (203)737-5219
>  mark.shifman@yale.edu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Connection pool stats

Posted by Mark Shifman <ma...@yale.edu>.
You can cast your datasource object to be a BasicDataSource
then the javadoc gives you all kinds of things you can get.
like getNumActive(), getNumIdle() etc
(for dbcp 1.3)
http://commons.apache.org/dbcp/api-1.3/index.html



Dhiren Bhatia wrote:
> I've configured my DB connection pool as follows:
> 
> context.xml
> 
> <Resource name="jdbc/myserver" auth="Container" type="javax.sql.DataSource"
> 
> maxActive="100" maxIdle="30" maxWait="10000" username="xxx"
> 
> password="xxx" driverClassName="com.mysql.jdbc.Driver"
> 
> url="jdbc:mysql://a.b.c:3306/Test" removeAbandoned="true"
> 
> removeAbandonedTimeout="60" logAbandoned="true" />
> 
> 
> web.xml
> 
> 
> <resource-ref>
> 
> <description>DB Connection</description>
> 
> <res-ref-name>jdbc/myserver</res-ref-name>
> 
> <res-type>javax.sql.DataSource</res-type>
> 
> <res-auth>Container</res-auth>
> 
> </resource-ref>
> 
> 
> In my code, I use a javax.sql.DataSource object to get connections and call
> connection.close() to return connections.
> 
> 
> How do I get stats on the connection pool? I would like to check how many
> connections are active/idle at any point in time.
> 
> 
> Thanks,
> 
> Dhiren
> 

-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shifman@yale.edu

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