I'm using Spring configuration file to configure C3P0. To monitor DataSource I configured net.bull.javamelody.SpringDataSourceFactoryBean
as mentioned in the user guide of javamelody. But my report is showing 0 Active jdbc connections where as my minPoolSize is 10. What did I miss?
In web.xml
added monitoring-spring.xml
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath:net/bull/javamelody/monitoring-spring.xml,
</param-value>
</context-param>
In Spring jdbc Configuration file is:
<bean id="sql2oDatasource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="#{dbProps['ops.jdbc.driverClassName']}"/>
<property name="jdbcUrl" value="#{dbProps['ops.jdbc.url']}"/>
<property name="user" value="#{dbProps['ops.jdbc.username']}"/>
<property name="password" value="#{dbProps['ops.jdbc.password']}"/>
<property name="maxPoolSize" value="#{dbProps['ops.c3p0.max_size']}"/>
<property name="minPoolSize" value="#{dbProps['ops.c3p0.min_size']}"/>
<property name="maxStatements" value="#{dbProps['ops.c3p0.max_statements']}"/>
<property name="checkoutTimeout" value="#{dbProps['ops.c3p0.timeout']}"/>
<property name="preferredTestQuery" value="SELECT 1"/>
</bean>
<!-- Configuring the session factory for SQL-2-O -->
<bean id="sql2oSession" class="org.sql2o.Sql2o">
<constructor-arg ref="wrappedDBDataSource"/>
<constructor-arg value="PostgreSQL" type="org.sql2o.QuirksMode"/>
</bean>
<bean id="wrappedDBDataSource" class="net.bull.javamelody.SpringDataSourceFactoryBean" primary="true">
<property name="targetName" value="sql2oDatasource"/>
</bean>
I tried to pass DriverClass
as net.bull.javamelody.JdbcDriver
in datasource and driver
as:
<property name="properties">
<props>
<prop key="driver">org.postgresql.Driver</prop>
</props>
</property>
But postgresql
driver is not getting registered this way.