Commons-dbcp - getting the active database connections
Joined: Jan 12, 2011
I have configured XA Datasource in JBOSS AS and the database is DB2. I want to get the number of active connections at any point of time for monitoring purpose. For that i tried using commons-dbcp. commons-dbcp has a BasicDataSource class which provides the API to get the actibve and idle connections.
So when i try to cast my datasource object to basicDataSource, it gives ClassCast exception. I checked the class name of the datasource returned by initialcontext. It is returning WrapperDataSource and not Datasource and i guess that is the reason for classcastexception.
Can anyone pease tell me how to get the number of active connections using dbcp jar. I also cannot change the underlying db implementation as its a huge applicationa d a very old application.