c3p0和MySql wait_timeout的问题

时间:2011-08-06 23:03:27

标签: mysql hibernate c3p0

我的网络应用程序中有一段时间后出现 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver 错误。 “有时”是8小时,但我发现默认情况下,如果没有发生任何事情,服务器会在8小时后关闭连接。所以我将“wait_timeout”更改为30秒。并将hibernate.cfg.xml中的hibernate.c3p0.idle_test_period属性更改为10秒

这是我的hibernate.cfg.xml属性

        <property name="connection.pool_size">20</property>
        <property name="hibernate.connection.zeroDateTimeBehavior">
           convertToNull
        </property>
        <property>
name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider
        </property>  
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">50</property>
        <property name="hibernate.c3p0.timeout">15</property>
        <property name="hibernate.c3p0.max_idle_time">18</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">10</property> 

这是我的c3p0属性

c3p0.preferredTestQuery = SELECT 1;

但我仍然得到同样的错误

0 个答案:

没有答案