我正在使用 Spring 配置文件来配置 C3P0。为了监控我net.bull.javamelody.SpringDataSourceFactoryBean
在 javamelody 的用户指南中提到的配置的 DataSource。但是我的报告显示 0 活动 jdbc 连接,而我的 minPoolSize 为 10。我错过了什么?
在web.xml
添加monitoring-spring.xml
<context-param>
<param-name>
contextConfigLocation
</param-name>
<param-value>
classpath:net/bull/javamelody/monitoring-spring.xml,
</param-value>
</context-param>
在 Spring jdbc 配置文件是:
<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>
我试图在数据源中传递,并DriverClass
作为:net.bull.javamelody.JdbcDriver
driver
<property name="properties">
<props>
<prop key="driver">org.postgresql.Driver</prop>
</props>
</property>
但是postgresql
司机没有以这种方式注册。