Hibernate c3p0配置参数在运行时不会受到影响

时间:2010-11-06 15:16:01

标签: mysql hibernate c3p0

我正在使用 c3p0-0.9.1.2.jar hibernate 3.2.1 。以下是hibernate配置。

    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/oDB</property>
    <property name="hibernate.connection.username">oDBUser</property>
    <property name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>
    <property name="hibernate.connection.autoReconnect">true</property>

    <property name="c3p0.max_size">10</property>
    <property name="c3p0.min_size">4</property>
    <property name="c3p0.timeout">1800</property>
    <property name="c3p0.max_statements">200</property>
    <property name="c3p0.maxStatementsPerConnection">5</property>
    <property name="c3p0.idle_test_period">1500</property>
    <property name="c3p0.acquire_increment">2</property>
    <property name="c3p0.testConnectionOnCheckout">true</property>
    <property name="c3p0.preferredTestQuery">SELECT 1</property>

但我认为像maxStatementsPerConnection,testConnectionOnCheckout和preferredTestQuery这样的参数在运行时没有任何影响。我应该为这些参数做些什么吗?这是我在日志中得到的内容。

  

INFO 2010-11-06 19:04:37,364初始化c3p0池... com.mchange.v2.c3p0.PoolBackedDataSource@e2da87d1 [connectionPoolDataSource - &gt; com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@412cca1a [acquireIncrement - &gt; 2,acquireRetryAttempts - &gt; 30,acquireRetryDelay - &gt; 1000,autoCommitOnClose - &gt; false,automaticTestTable - &gt; null,breakAfterAcquireFailure - &gt; false,checkoutTimeout - &gt; 0,connectionCustomizerClassName - &gt; null,connectionTesterClassName - &gt; com.mchange.v2.c3p0.impl.DefaultConnectionTester,debugUnreturnedConnectionStackTraces - &gt; false,factoryClassLocation - &gt; null,forceIgnoreUnresolvedTransactions - &gt; false,identityToken - &gt; z8kfsx8c99kx7g8xqvs4 | 87400,idleConnectionTestPeriod - &gt; 1500,initialPoolSize - &gt; 4,maxAdministrativeTaskTime - &gt; 0,maxConnectionAge - &gt; 0,maxIdleTime - &gt; 1800,maxIdleTimeExcessConnections - &gt; 0,maxPoolSize - &gt; 10,maxStatements - &gt; 200, maxStatementsPerConnection - &gt; 0 ,minPoolSize - &gt; 4,nestedDataSource - &gt; com.mchange.v2.c3p0.DriverManagerDataSource@9d074b3f [description - &gt; null,driverClass - &gt; null,factoryClassLocation - &gt; null,identityToken - &gt; z8kfsx8c99kx7g8xqvs4 | b245dc,jdbcUrl - &gt; jdbc:mysql:// localhost:3306 / oDB,properties - &gt; {autoReconnect = true,user = * ,密码= * ,zeroDateTimeBehavior = convertToNull}], preferredTestQuery - &gt; null ,propertyCycle - &gt; 0,testConnectionOnCheckin - &gt; false, testConnectionOnCheckout - &gt; false ,unreturnedConnectionTimeout - &gt; 0,usesTraditionalReflectiveProxies - &gt;假; userOverrides:{}],dataSourceName - &gt; null,factoryClassLocation - &gt; null,identityToken - &gt; z8kfsx8c99kx7g8xqvs4 | 93c5e7,numHelperThreads - &gt; 3]

提前致谢。 古拉

1 个答案:

答案 0 :(得分:2)

  

但我认为像maxStatementsPerConnection,testConnectionOnCheckout和preferredTestQuery这样的参数在运行时没有任何影响。我应该为这些参数做些什么吗?

他们没有进入Hibernate配置文件,您需要提供c3p0.properties文件。请参阅C3P0文档中的Appendix C: Hibernate-specific notes