java - 使用c3p0.idle_test_period。

标签 java hibernate c3p0

我是 c3op 的新手,对 : 的使用感到困惑

c3p0.idle_test_period

在此链接中:HowTo configure the C3P0 connection pool

idleTestPeriod :  Must be set in hibernate.cfg.xml (or hibernate.properties), Hibernate default:  
0, If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out  
connections, every this number of seconds.

这种测试(idel,pooled connections)的目的是什么,c3p0.idle_test_period和c3p0.timeout有什么关系?

最佳答案

数据库服务器可能会在一定时间后关闭其端的连接 - 导致您的应用程序出现错误,因为它会尝试在服务器端不再可用的连接上发送查询。

为了避免这种情况,您可以让池定期检查连接(想想 ping)的有效性。这就是 idle_test_period 的用途。

timeout 是池将从池中删除连接的时间跨度,因为该连接有一段时间未 check out (使用)并且池包含的连接数多于 c3pO.min_size.

关于java - 使用c3p0.idle_test_period。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10175957/

相关文章:

spring - 无法让 c3p0 与 Spring/Hibernate/JPA 一起使用

mysql - 连接被数据库丢弃

java - 如何以编程方式表示 Magic The Gathering 的类型转换成本?

java - org.springframework.dao.InvalidDataAccessApiUsageException

Javaparser:用一种方法访问所有节点类型

java - 找不到元素 'hibernate-configuration' 的声明但它存在

JAVA - hibernate - 在 DAO 中创建新查询

jdbcTemplate 在长时间更新时挂起

java - 使用星号向前和向后打印直角三角形?

java - 正在运行引用另一个 jar 的 jar