`

nested exception is org.hibernate.TransactionException: JDBC rollback failed

阅读更多

nested exception is org.hibernate.TransactionException: JDBC rollback failed

为hibernate配置连接池,推荐用c3p0,然后配置c3p0的反空闲设置idle_test_period,只要小于MySQL的wait timeout即可。
在hibernate.cfg.xml中增加下面几项:
<!-- configuration pool via c3p0-->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider </property>
<property name="c3p0.min_size">5 </property>
<property name="c3p0.max_size">30 </property>
<property name="c3p0.time_out">1800 </property> <!-- seconds --> <!-- default: 0 -->
<property name="c3p0.max_statement">50 </property> <!-- default: 0 -->
<property name="c3p0.acquire_increment">1 </property> <!-- default: 1 -->
<property name="c3p0.idle_test_period">120 </property>  <!-- seconds --> <!-- default: 0 -->
<property name="c3p0.validate">true </property>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics