首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hibernate C3P0问题

Hibernate C3P0问题
EN

Stack Overflow用户
提问于 2012-08-27 17:53:37
回答 1查看 966关注 0票数 0

我正在尝试使用c3p0设置,以使应用程序自动丢弃陈旧的连接,并自动重新建立连接。我在sessionfactoryprovider类中设置了以下配置属性:

代码语言:javascript
复制
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;

有人能建议我该如何调试这个吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-27 19:46:27

尝试在log4j-配置中设置c3p0的日志记录级别以进行调试:

代码语言:javascript
复制
log4j.category.com.mchange=DEBUG
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12146975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档