0

我正在尝试使用 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");

我在应用程序中没有找到任何日志,试图执行测试查询,也没有在数据库重启后恢复。“show_sql”在属性文件中设置为 true,在日志中,我可以看到其他查询正在执行。
包版本如下: C3P0 = 0.9.1.2;休眠注释= 3.3;休眠 = 3.3;

有人可以建议我应该如何进行调试吗?

4

1 回答 1

0

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

log4j.category.com.mchange=DEBUG
于 2012-08-27T19:46:27.793 回答