tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Discover the Datasource connection pool maxSize.
Date Wed, 03 Nov 2010 13:47:29 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

GF,

On 11/3/2010 7:15 AM, GF wrote:
> i've not access to Tomcat's server.xml where the sysadmins defined a resource:
> 
> <Resource driverClassName="oracle.jdbc.driver.OracleDriver"
> maxActive="65" maxIdle="30" maxWait="5" name="myDatasource"
> type="javax.sql.DataSource" url="jdbc:....." />
> 
> I wish to discover from a web appplication deployed on that Tomcat
> what's the configuration  "maxActive" for myDatasource.

Try something like this:

import org.apache.tomcat.dbcp.dbcp.BasicDataSource;

...

DataSource ds = (DataSource)ctx.lookup("java:/comp/env/jdbc/myDataSource");

if(ds instanceof BasicDataSource)
{
  BasicDataSource bds = (BasicDataSource)ds;

  maxActiveConnections = bds.getMaxActive();
  maxIdleConnections = bds.getMaxIdle();
  minIdleConnections = bds.getMinIdle();
  activeConnections = bds.getNumActive();
  idleConnections = bds.getNumIdle();
}

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

iEYEARECAAYFAkzRZ/AACgkQ9CaO5/Lv0PBZ9gCfZjFjk57HQJ0TkCX3DLJ7qwg0
xIwAnjlfrs9tNXk5URhrLYGHUzgSMTi/
=i8zY
-----END PGP SIGNATURE-----

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


Mime
View raw message