http://www.mchange.com/projects/c3p0/#configuration_properties
spring+hibernate
连接池
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/openfire"/>
<property name="user" value="root"/>
<property name="password" value="password"/>
</bean>
</beans>
tomcat jndi:
<Resource auth="Container"
description="DB Connection"
driverClass="com.mysql.jdbc.Driver"
maxPoolSize="4"
minPoolSize="2"
acquireIncrement="1"
name="jdbc/TestDB"
user="test"
password="ready2go"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:mysql://localhost:3306/test?autoReconnect=true" />
建议:c3p0.propertyies
c3p0.acquireIncrement=5
c3p0.idleConnectionTestPeriod=1800
c3p0.initialPoolSize=5
c3p0.maxIdleTime=1000
c3p0.maxPoolSize=20
c3p0.maxStatements=100
c3p0.minPoolSize=5
just hibernate:
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
调优:在我的环境下
maxpoolSize 30, 1822 , 15, 1655 。 可能和测试过程有关。
maxStatement 加上, 3600。严重影响性能。
扩大 xms xmx 512 ,957
西津渡