How to configure JavaMelody to monitor Jdbc connections in C3p0 DataSource

I am using Spring configuration file to configure C3P0. For monitoring the DataSource, I am configured net.bull.javamelody.SpringDataSourceFactoryBeanas indicated in the javamelody user guide. But my report shows 0 active jdbc connections, where since my minPoolSize is 10. What I missed.

In web.xmladdedmonitoring-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

<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 convey DriverClassboth net.bull.javamelody.JdbcDriverin the data source and driverhow

   <property name="properties">
        <props>
            <prop key="driver">org.postgresql.Driver</prop>
        </props>
    </property>

But the driver is postgresqlnot registered this way.

+4
source share
1 answer

. db, , , .

, db , db - , db . 0 ( ). , . , db .

0

Source: https://habr.com/ru/post/1692296/


All Articles