Hibernate is not re-using the connections in the pool. When I do "show processlist" in mysql, I can see most of them are in "Sleep" state. The pool keeps growing over time, by my specified increment, until I eventually run out.
Here's the snippet from the spring data configuration xml:
Code:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydb"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="user" value="myuser"/>
<property name="password" value="mypass"/>
<property name="initialPoolSize" value="10"/>
<property name="minPoolSize" value="10"/>
<property name="maxPoolSize" value="100"/>
<property name="acquireIncrement" value="5"/>
<property name="maxStatementsPerConnection" value="5" />
<property name="maxIdleTime" value="7200" />
<property name="maxConnectionAge" value="14400" />
<property name="acquireRetryAttempts" value="10"/>
<property name="testConnectionOnCheckin" value="false" />
<property name="preferredTestQuery" value="SELECT 1;" />
<property name="idleConnectionTestPeriod" value="3600" />
</bean>
......
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
<prop key="hibernate.jdbc.use_get_generated_keys">true</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.c3p0.initialPoolSize">10</prop>
<prop key="hibernate.c3p0.minPoolSize">10</prop>
<prop key="hibernate.c3p0.maxPoolSize">100</prop>
<prop key="hibernate.c3p0.acquireIncrement">5</prop>
<prop key="hibernate.c3p0.maxStatementsPerConnection">5</prop>
<prop key="hibernate.c3p0.maxIdleTime">7200</prop>
<prop key="hibernate.c3p0.maxConnectionAge">14400</prop>
<prop key="hibernate.c3p0.acquireRetryAttempts">10</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckin">false </prop>
<prop key="hibernate.c3p0.preferredTestQuery">SELECT 1;</prop>
<prop key="hibernate.c3p0.idleConnectionTestPeriod">1800 </prop>
</props>
</property>
</bean>
Any suggestions?
I'm using the following:
c3p0 0.9.1.2
hibernate 3.2.2.ga
spring 2.0.2
Tomcat 5.5.25
Mysql 4.1.20
What other information should I provide?
Thanks!!!
Hibernate version: 3.2.2.ga Code between sessionFactory.openSession() and session.close():
Where do I find this in Spring?
Name and version of the database you are using:
Mysql 4.1.20Code: