Java 休眠C3P0问题

Java 休眠C3P0问题,java,hibernate,c3p0,Java,Hibernate,C3p0,我正在尝试使用c3p0设置,以使应用程序能够自动放弃过时的连接,并自动重新建立连接。我已在sessionfactoryprovider类中设置了以下配置属性: configuration.setProperty("hibernate.c3p0.min_size", c3p0 .get("minPoolSize") != null ? c3p0.get("minPoolSize") : "1"); configuration.setP

我正在尝试使用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; HibernateAnnotations=3.3; Hibernate=3.3


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

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

log4j.category.com.mchange=DEBUG

正如建议的那样,我已经将日志级别设置为DEBUG。我可以看到所有这些属性都是在“SessionFactory”中设置的。但是,查询仍然没有定期执行。是否使用您的设置?检查属性名称是否正确,并验证C3P0是否确实在使用您的设置。上次我设置c3p0时,在配置属性名称中有一些奇怪的东西(有“hibernate.c3p0.”和没有)。最后,我在Spring配置xml中直接将这些值设置为C3P0的ComboPooledDataSource,这似乎解决了这个问题。非常感谢您提出将日志级别设置为debug的建议。这有助于找到问题的根源。事实证明,我根本没有使用c3p0ConnectionProvider。其他一些连接提供程序被设置为默认,因此无法获取属性