获取org.hibernate.util.JDBCExce ptionReporter

时间:2012-11-27 07:17:19

标签: hibernate openjpa c3p0

我有一个使用hibernate和OpenJPA进行数据库连接的Web应用程序。但是当应用程序空闲超过8小时时,我在日志文件中遇到以下错误。

24 Nov 2012 05:54:28 1206290820 [http-8080-20] ERROR org.hibernate.util.JDBCExce ptionReporter - The last packet successfully received from the server was 118,4 45,988 milliseconds ago. The last packet sent successfully to the server was 11 8,445,989 milliseconds ago. is longer than the server configured value of 'wait_ timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for cli ent timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 24 Nov 2012 05:54:28 1206290820 [http-8080-20] DEBUG org.hibernate.ejb.AbstractE ntityManagerImpl - mark transaction for rollback 24 Nov 2012 05:54:28 1206290820 [http-8080-20] ERROR root - org.hibernate.excep tion.JDBCConnectionException: could not execute query

我有以下persistence.xml条目

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> <property name="hibernate.connection.url" value="jdbc:mysql://xxx.xxx.xxx.xxx:3306/lbs?autoReconnect=true"/> <property name="hibernate.c3p0.min_size" value="5"/> <property name="hibernate.c3p0.max_size" value="20"/> <property name="hibernate.c3p0.timeout" value="1800"/> <property name="hibernate.c3p0.max_statements" value="50"/> <property name="hibernate.c3p0.idle_test_period" value="1800"/> <property name="c3p0.idleConnectionTestPeriod" value="1810"/>

在其中一个question!在Stackoverflow论坛上,他们说我们应该每次关闭EntityManager对象。

在我的应用程序中,我正在为EntityManager做以下事情

我正在创建EntityManager作为我在整个应用程序中使用的单例类。

我错过了什么吗?

更新

c3p0初始化的日志条目是:

INFO org.hibernate.connection.ConnectionProviderFactory - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider

INFO org.hibernate.connection.C3P0ConnectionProvider - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://xxx.xxx.xxx.xxx:3306/lbs?autoReconnect=true

INFO org.hibernate.connection.C3P0ConnectionProvider - Connection properties: {user=****, password=****, autocommit=true, release_mode=auto}

INFO org.hibernate.connection.C3P0ConnectionProvider - autocommit mode: true

WARN org.hibernate.connection.C3P0ConnectionProvider - Both hibernate-style property 'hibernate.c3p0.idle_test_period' and c3p0-style property 'c3p0.idleConnectionTestPeriod' have been set in hibernate.properties. Hibernate-style property 'hibernate.c3p0.idle_test_period' will be used and c3p0-style property 'c3p0.idleConnectionTestPeriod' will be ignored!

INFO com.mchange.v2.log.MLog - MLog clients using log4j logging.

INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]

DEBUG com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean - MBean: com.mchange.v2.c3p0:type=PooledDataSource[2ryrhz8rc8xlpn1l7vn76|1b15828] registered.

DEBUG com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean - MBean: com.mchange.v2.c3p0:type=PooledDataSource[2ryrhz8rc8xlpn1l7vn76|1b15828] unregistered, in order to be reregistered after update.

DEBUG com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean - MBean: com.mchange.v2.c3p0:type=PooledDataSource[2ryrhz8rc8xlpn1l7vn76|1b15828] registered.

INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@a340a84b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@454eed4 [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2ryrhz8rc8xlpn1l7vn76|8010fe, idleConnectionTestPeriod -> 1800, initialPoolSize -> 5, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@f50d6507 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 2ryrhz8rc8xlpn1l7vn76|1233a8e, jdbcUrl -> jdbc:mysql://xxx.xxx.xxx.xxx:3306/lbs?autoReconnect=true, properties -> {user=******, password=******, autocommit=true, release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 2ryrhz8rc8xlpn1l7vn76|1b15828, numHelperThreads -> 3 ]

DEBUG com.mchange.v2.resourcepool.BasicResourcePool - incremented pending_acquires: 1 DEBUG com.mchange.v2.resourcepool.BasicResourcePool - incremented pending_acquires: 2 DEBUG com.mchange.v2.resourcepool.BasicResourcePool - incremented pending_acquires: 3 DEBUG com.mchange.v2.resourcepool.BasicResourcePool - incremented pending_acquires: 4 DEBUG com.mchange.v2.resourcepool.BasicResourcePool - incremented pending_acquires: 5

DEBUG com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@1148d7f config: [start -> 5; min -> 5; max -> 20; inc -> 3; num_acq_attempts -> 30; acq_attempt_delay -> 1000; check_idle_resources_delay -> 1800000; mox_resource_age -> 0; max_idle_time -> 1800000; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; expiration_enforcement_delay -> 450000; break_on_acquisition_failure -> false; debug_store_checkout_exceptions -> false]

DEBUG com.mchange.v2.resourcepool.BasicResourcePool - acquire test -- pool size: 0; target_pool_size: 5; desired target? 1

DEBUG com.mchange.v2.resourcepool.BasicResourcePool - awaitAvailable(): [unknown] DEBUG com.mchange.v2.resourcepool.BasicResourcePool - trace com.mchange.v2.resourcepool.BasicResourcePool@1148d7f [managed: 0, unused: 0, excluded: 0]

0 个答案:

没有答案