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 <mark.shif...@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.shif...@yale.edu > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >