我正在尝试使用c3p0设置,以使应用程序自动丢弃陈旧的连接,并自动重新建立连接。我在sessionfactoryprovider类中设置了以下配置属性:
configuration.setProperty("hibernate.c3p0.min_size", c3p0
.get("minPoolSize") != null ? c3p0.get("minPoolSize")
: "1");
configuration.setProperty("hibernate.c3p0.max_size", c3p0
.get("maxPoolSize") != null ? c3p0.get("maxPoolSize")
: "50");
configuration.setProperty("hibernate.c3p0.timeout", c3p0
.get("maxIdleTime") != null ? c3p0.get("maxIdleTime")
: "900");
configuration.setProperty(
"hibernate.c3p0.acquireRetryAttempts",
c3p0.get("acquireRetryAttempts") != null ? c3p0
.get("acquireRetryAttempts") : "30");
configuration.setProperty(
"hibernate.c3p0.acquireIncrement",
c3p0.get("acquireIncrement") != null ? c3p0
.get("acquireIncrement") : "5");
configuration.setProperty(
"hibernate.c3p0.idleConnectionTestPeriod",
c3p0.get("idleConnectionTestPeriod") != null ? c3p0
.get("idleConnectionTestPeriod") : "60");
configuration.setProperty("hibernate.c3p0.initialPoolSize", c3p0
.get("minPoolSize") != null ? c3p0.get("minPoolSize")
: "1");
configuration.setProperty(
"hibernate.c3p0.maxStatements",
c3p0.get("maxStatementsPerConnection") != null ? c3p0
.get("maxStatementsPerConnection")
: "0");
configuration.setProperty("preferredTestQuery", "select 1 from dual");
configuration.setProperty("hibernate.c3p0.testConnectionOnCheckin",
"true");
configuration.setProperty("hibernate.c3p0.testConnectionOnCheckout",
"true");
configuration.setProperty("testConnectionOnCheckin", "true");
configuration.setProperty("hibernate.c3p0.preferredTestQuery",
"select 1 from dual");我没有在应用程序中找到任何试图执行测试查询的日志,也没有在db重新启动后恢复。"show_sql“设置为true在属性文件和日志中,我可以看到其他查询正在执行。
包版本如下: C3P0 = 0.9.1.2;HibernateAnnotations = 3.3;Hibernate = 3.3;
有人能建议我该如何调试这个吗?
发布于 2012-08-27 19:46:27
尝试在log4j-配置中设置c3p0的日志记录级别以进行调试:
log4j.category.com.mchange=DEBUGhttps://stackoverflow.com/questions/12146975
复制相似问题