6

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.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
udaybhaskar
  • 159
  • 5
  • 16

1 Answers1

0

Your configuration looks ok according to documentation. You see db active connection, pool size values on report that also means your config is ok.

In the other hand active db connection count means how many connections from db connection pool is connection operating with db at that moment. 0 active connections is good for you(if your application is working properly). It means your db operations are quickly done. It is hard to catch active connection while db operations are fast.

Mehmet Sunkur
  • 2,373
  • 16
  • 22
  • 1
    Number of active jdbc connections graph is showing nothing.Its just empty graph.At least there should be some spikes.Active jdbc connection and pool size isn't same ??. – udaybhaskar Jan 29 '18 at 05:51
  • Active connections count and pool size are not the same. I am not sure why your graph is empty. May be your db activity is too low see. You can simulate a high db activity for a period then check the graph. – Mehmet Sunkur Jan 29 '18 at 07:02