在dataSource中添加
<property name="idleConnectionTestPeriod" value="600"/>
<property name="preferredTestQuery" value="select id from BLOG_ARTICLE where id=1"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="testConnectionOnCheckout" value="true"/>
即:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="idleConnectionTestPeriod" value="600"/>
<property name="preferredTestQuery" value="select id from tableName where id=1"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="testConnectionOnCheckout" value="true"/>
</bean>
配置c3p0的目的是解决Could not open Hibernate Session for transaction问题,即mysql每隔八小时断开问题。
<property name="idleConnectionTestPeriod" value="600"/>
<property name="preferredTestQuery" value="select id from BLOG_ARTICLE where id=1"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="testConnectionOnCheckout" value="true"/>
即:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="idleConnectionTestPeriod" value="600"/>
<property name="preferredTestQuery" value="select id from tableName where id=1"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="testConnectionOnCheckout" value="true"/>
</bean>
配置c3p0的目的是解决Could not open Hibernate Session for transaction问题,即mysql每隔八小时断开问题。