c3p0 和 MySql wait_timeout
我收到错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 连接关闭后不允许进行任何操作。连接已 由驱动程序隐式关闭
在我的网络应用程序中一段时间后, 。这个“某个时间”是 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;
但我仍然遇到相同的错误。
I'm getting error:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
No operations allowed after connection closed.Connection was
implicitly closed by the driver
after sometime in my webapp. That "sometime" was 8 hrs but I found out that by default, the server closes the connection after eight hours if nothing has happened. So i changed "wait_timeout" to 30 sec. and changed hibernate.c3p0.idle_test_period
property in hibernate.cfg.xml to 10 sec
Here's my hibernate.cfg.xml properties
<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>
Here's my c3p0 properties:
c3p0.preferredTestQuery = SELECT 1;
But I'm still getting the same error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论