-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Chuck,
On 7/12/2010 10:38 AM, Caldarale, Charles R wrote: >> From: Ashish Kulkarni [mailto:ashish.kulkarn...@gmail.com] >> Sent: 2010 July 12, Monday 09:16 >> To: Tomcat Users List; p...@pidster.com >> Subject: Re: tomcat datasource, find active connections >> >> Where do i specify data source factory? > > http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#Adding_Custom_Resource_Factories As much fun as that sounds, the OP could just use the default DataSourceFactory which is based upon DBCP. We use the following in a "health check" JSP we have. import org.apache.tomcat.dbcp.dbcp.BasicDataSource; Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/mydb"); if(null == ds) throw new NamingException("Cannot obtain DataSource"); int maxActiveConnections = 0; int maxIdleConnections = 0; int minIdleConnections = 0; int activeConnections = 0; int idleConnections = 0; if(ds instanceof BasicDataSource) { BasicDataSource bds = (BasicDataSource)ds; maxActiveConnections = bds.getMaxActive(); maxIdleConnections = bds.getMaxIdle(); minIdleConnections = bds.getMinIdle(); activeConnections = bds.getNumActive(); idleConnections = bds.getNumIdle(); } Feel free to add more types of DataSource to fetch their counters. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw9MvkACgkQ9CaO5/Lv0PAoUwCffLW2kYhnQY/1uYP+NcrQDvjy GIgAnRa/VgcfHBm114eW5LgxlJBTmv7I =QwO9 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org