关于hibernate使用c3p0连接池的问题.
曾经一个已经投入运行的项目,是用struts+hibernate组件,后来再把工程打开来运行时,配置不变的情况下,却提示:
10:40:11,046 INFO C3P0Registry:77 - Initializing c3p0-0.9.0 [built 11-July-2005 00:43:29 -0400; debug? true; trace: 10]
10:40:11,562 INFO PoolBackedDataSource:257 - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1606bf5 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@196c0a0 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 196c0a0, idleConnectionTestPeriod -> 100, initialPoolSize -> 10, maxIdleTime -> 100, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@29d838 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 29d838, jdbcUrl -> jdbc:microsoft:sqlserver://localhost:1433, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 1606bf5, numHelperThreads -> 3 ]
10:41:14,093 WARN BasicResourcePool:1222 - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@f8db08 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
10:41:14,515 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: file:/D:/Tomcat/work/Catalina/localhost/KBPM/loader/ehcache-failsafe.xml
10:41:15,281 WARN BasicResourcePool:1222 - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@4dd413 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
10:42:29,546 WARN BasicResourcePool:1222 - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@19d56e9 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
10:42:29,546 ERROR JDBCExceptionReporter:72 - Connections could not be acquired from the underlying database!
10:42:29,578 ERROR BaseHibernateDAO:204 - 查询数据库失败
10:42:29,578 INFO ConfigConstants:40 - 调用getProperty
10:42:29,578 WARN RequestProcessor:516 - Unhandled Exception thrown: class java.lang.NullPointerException
----------------------------------------------------
hibernate的配置文件关于c3p0的代码片段如下:
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">30</property>
<property name="c3p0.idle_test_period">100</property> <!-- seconds -->
<property name="c3p0.max_size">100</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">100</property> <!-- seconds -->
<!-- DEPRECATED very expensive property name="c3p0.validate>-->
其中c3p0.acquire_increment曾设成1,10,100,31如今是设成30,但都是一样的效果,请熟悉的人指点一下原因.