Results 1 to 1 of 1
- 01-13-2011, 04:57 AM #1
Member
- Join Date
- May 2010
- Posts
- 9
- Rep Power
- 0
commons-dbcp - Getting the active and idle db connections
Hi,
I have an application deployed on jboss. DB used is db2. For monitoring purpose i need to get the number of active and idle connections at any point of time. I am trying to use commons-dbcp jar to get this data using BasicDataSourceClass. Following is the piece of code.
Context initialContext;
initialContext = new InitialContext();
DataSource ds = (DataSource) initialContext.lookup(myjndiname);
BasicDataSource bds = (BasicDataSource) datasource;
logger.info("************CONNECTION POOL DATA-> ACTIVE CONN=" + bds.getNumActive() + " IDLE CONN=" + bds.getNumIdle() + " INIT SIZE=" + bds.getInitialSize());
This code gave a class cast exception at the point where datasource is cast to BasicDataSource. The class name returned by variable "ds" is WrapperDataSource and not DataSource which is why class cast exception was thronw. Does anyone know :-
1. What configurations do i need so that datasource returned by InitialContext is BasicDataSource? FYI i tried to add the BasicDataSourceFactory in db2-ds.xml. But it still didnt work. I also cannot change the underlying functionality of db pool implementation as its a huge application.
ThanksLast edited by userj2ee; 01-13-2011 at 05:07 AM.
Similar Threads
-
find a prime number
By loja11 in forum Threads and SynchronizationReplies: 4Last Post: 02-17-2011, 08:54 AM -
How to find the active Window in Swing?
By akcasoy in forum AWT / SwingReplies: 16Last Post: 06-26-2010, 05:33 PM -
Find a number from a string
By florentp in forum New To JavaReplies: 2Last Post: 03-20-2009, 09:01 PM -
Find all permutations of a number
By matzahboy in forum New To JavaReplies: 6Last Post: 12-02-2008, 03:59 AM -
Find nth root of a number
By perito in forum New To JavaReplies: 1Last Post: 03-03-2008, 06:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks