DB接続プーリングにc3p0を使用している永続性レイヤとして、Hibernateを使用してMySQL 5データベースに接続するJavaサーバがあります。Hibernate c3p0接続プールがアイドル接続をタイムアウトしない
私はC3P0以下試してみたとドキュメント休止状態:
を私たちは、生産上のエラーを取得していますサー
... Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
BEGIN NESTED EXCEPTION
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
MESSAGE: The last packet successfully received from the server was45000 seconds ago.The last packet sent successfully to the server was 45000 seconds ago, which 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 client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
STACKTRACE:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was45000 seconds ago.The last packet sent successfully to the server was 45000 seconds ago, which 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 client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
次のように我々はC3P0接続プールのプロパティを設定しているが:
default MySQL wait_timetoutは28800秒(8時間)に設定されているhibernate.c3p0.max_size=10
hibernate.c3p0.min_size=1
hibernate.c3p0.timeout=5000
hibernate.c3p0.idle_test_period=300
hibernate.c3p0.max_statements=100
hibernate.c3p0.acquire_increment=2
、報告されたエラーが、それはオーバーをされていると言っていることを示すVERS 45000秒(約12.5時間)。 c3p0の設定では、5000秒後に使用されなかったアイドル状態の接続を「タイムアウト」し、300秒ごとにチェックするため、アイドル状態の接続は5299秒より長くはならないと記載されていますか?
私は開発者MySQL(Windowsの場合はmy.ini、Unixの場合はmy.cnf)をwait_timeout = 60に設定し、c3p0アイドルタイムアウト値を60秒以下に設定してローカルでテストしました。新しいもの。また、私たちがDB接続を漏らしておらず、接続を保持していないことを確認します。それは私たちのようには見えません。
私の開発環境でc3p0.propertiesファイルをテストして、c3p0が接続を適切に処理していることを確認しています。
hibernate.properties(MySQLのWAIT_TIMEOUTでテスト= 60)
hibernate.c3p0.max_size=10
hibernate.c3p0.min_size=1
hibernate.c3p0.timeout=20
hibernate.c3p0.max_statements=100
hibernate.c3p0.idle_test_period=5
hibernate.c3p0.acquire_increment=2
c3p0.properties
com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=ALL
com.mchange.v2.log.MLog=com.mchange.v2.log.FallbackMLog
c3p0.debugUnreturnedConnectionStackTraces=true
c3p0.unreturnedConnectionTimeout=10
私の答えを見て、hibernate.orgにある互換性マトリックスをチェックしてみてください。(たとえ私がそのマトリックスのc3p0を逃しても) – Schildmeijer