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>

你可能感兴趣的:(Hibernate,mysql,xml,jdbc)