c3po配置和mysql中止连接

时间:2016-12-20 16:49:16

标签: java mysql c3p0

我在数据库端收到了很多Aborted connection条消息 - [Note] Aborted connection 11043 to db: 'mysql' user: 'mysql' host: Got an error reading communication packets

我对应用程序和数据库没有任何问题,但我想知道为什么我会收到这些消息。

可能是因为hibernate.c3p0.idle_test_periods高于hibernate.c3p0.timeout吗?

这是hibernate配置文件:

hibernate.id.new_generator_mappings=false
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.format_sql=false
hibernate.max_fetch_depth=3
hibernate.show_sql=false
hibernate.use_sql_comments=false
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=com.p.db.pMySqlDialect
hibernate.connection.release_mode=after_transaction
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.idle_test_period=10
hibernate.c3p0.timeout=0
hibernate.c3p0.max_statements=0
hibernate.c3p0.min_size=3
hibernate.c3p0.max_size=400
hibernate.c3p0.preferredTestQuery=select 1
hibernate.c3p0.acquireRetryAttempts=5
hibernate.c3p0.acquireRetryDelay=1000
hibernate.c3p0.breakAfterAcquireFailure=false
hibernate.c3p0.testConnectionOnCheckin=false
hibernate.c3p0.testConnectionOnCheckout=false

数据库访问日志:

DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#2] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@41d8a248] on IDLE CHECK has SUCCEEDED.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#1] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7d10203] on IDLE CHECK.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#0] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@264d3257] on IDLE CHECK.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#2] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@ea7e8fb] on IDLE CHECK.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#0] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@264d3257] on IDLE CHECK has SUCCEEDED.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#1] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Test of PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@7d10203] on IDLE CHECK has SUCCEEDED.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#0] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Testing PooledConnection [com.mchange.v2.c3p0.impl.NewPooledConnection@2cb753e7] on IDLE CHECK.>
DEBUG [C3P0PooledConnectionPoolManager[identityToken->z8kfsx9l7vpkfr1egte0l|cf2bf60]-HelperThread-#2] [UID:, MSG_ID:] [com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool] <Test of PooledConnection

1 个答案:

答案 0 :(得分:1)

连接最终变得陈旧。请配置一些连接测试。最简单的方法就是修改配置以便

hibernate.c3p0.testConnectionOnCheckout=true

或者,请参阅c3p0 docs