简体   繁体   English

Hibernate C3P0问题

[英]Hibernate C3P0 Issue

I am trying to use the c3p0 settings , to enable the application to auto discard a stale connection, and reestablish the connection automatically.I have set the configuration properties as below in the sessionfactoryprovider class : 我正在尝试使用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");

I don't find any logs in the application , trying to execute the test query, nor is it recovering after a db restart. 我在应用程序中找不到任何日志,尝试执行测试查询,也没有在数据库重新启动后恢复。 "show_sql" s set to true in the properties file, and in the logs, I can see the other queries executing. 在属性文件中将“ show_sql”设置为true,在日志中,我可以看到其他查询正在执行。
The package versions are as follows : C3P0 = 0.9.1.2; 软件包版本如下: C3P0 = 0.9.1.2; HibernateAnnotations = 3.3; HibernateAnnotations = 3.3; Hibernate = 3.3; 休眠= 3.3;

Could someone please suggest how I should go about debugging this ? 有人可以建议我应该如何调试吗?

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

log4j.category.com.mchange=DEBUG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM