连接池中的连接无效

Connection is invalid in connection pooling

我在 java 应用程序中使用 c3p0 作为连接池。我们写了与之相关的所有属性,我的 wait_timeout 值为 60。我们无法增加 wait_timeout 值。我收到错误 "connection is invalid"。如何处理这个错误。

您应该设置 max_idle_time 等待超时;例如:

<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">60</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">10</property> 

看到这个 link : http://www.mchange.com/projects/c3p0/index.html#configuration_files

你可以在 stack overflow 中找到同样的问题:

Hibernate c3p0 connection pool not timing out idle connections

c3p0 maxIdleTime is same as wait_timeout of mysql?