Using java/Spring/Ibatis sqlserver is the database and datasource is org.apache.commons.dbcp.BasicDataSource following is the data source object i want to expose real time connection pool count like how many are right now in use and how many in idle and i want to monitor using jmx any quick idea how to implement
<bean id="wssModelDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="net.sourceforge.jtds.jdbcx.JtdsDataSource"/>
<property name="url" value="com.wss.jdbc.ConnectionUrl=jdbc:jtds:sqlserver://x-x2/x_control_QA;appName=wss;sendStringParametersAsUnicode=false;loginTimeout=20;socketTimeout=180"/>
<property name="username" value="xxx"/>
<property name="password" value="xxx"/>
<property name="maxActive" value="10"/>
<property name="maxWait" value="10000"/>
</bean>
Yes we can do it, simply enable jmx for your dao class which have jdbcTemplate injected and being used by dao methods and use create public getter methods returning value of following methods and here you go jmx can monitor for you.
http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html