2012-03-12 127 views
5

Java/Tomcat6/Debian SqueezeアプリケーションがMySqlサーバーと通信できないことがあります。 Tomcatアプリケーションはフロントエンドサーバーにあり、MySqlは別のMySql専用ボックスにあります。一般的なエラーは次のとおりです。'autoReconnect = true'の場合でもMySql JDBCタイムアウト

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was56588 milliseconds ago. 

The last packet sent successfully to the server was 56588 milliseconds 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. 

タイムアウト時間はわずか60秒ですが、非常に短いようです。 1時間以上の場合は、数分ごとにDBサーバーにpingを実行するバックグラウンドタスクを設定するだけです。 autoReconnectパラメータを開始URLに追加しました。明らかな影響はありません。問題はここにあるものになど

任意のアイデア? ありがとう pat

+1

は、http://stackoverflow.com/q/667289/778687 – tusar

+0

@tusarリンクのおかげで、この記事を参照してください。なぜ私はたくさんのコードを書いているのかを説明します。興味深いことに、彼らは自動再接続を非難しています。 – fishtoprecords

+0

サーバ上でwait_timeoutがどのように設定されていますか? –

答えて

0

ネットワークの不具合をコードし、自分で自動再接続する必要があります。

自動再接続は意図的にオフになっています。これは、接続が解除されたときにサイレントに発生し、の別の状態に戻ってくるいくつかの「アプリケーション」バグです。

とにかく、これはやや重複した質問であるとのコメントがあります。この問題を克服するための

0

構成しC3P0プロパティ。 JDBC接続URLで

hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider 
hibernate.c3p0.min_size=0 
hibernate.c3p0.max_size=20 
hibernate.c3p0.timeout=500 
hibernate.c3p0.max_statements=50 
hibernate.c3p0.idle_test_period=3000 
hibernate.c3p0.testConnectionOnCheckout=true 
hibernate.c3p0.acquire_increment=1 

、などのプロパティを使用しurl=jdbc:mysql://host/databasename?autoReconnect=true

+0

'autoReconnect'は廃止し、推奨されない([コネクタ/ J参照]のプロパティの記述を参照して(https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration -properties.html#connector-j-reference-set-config)または[セクション15.4]の最後の注記(https://dev.mysql.com/doc/connector-j/5.1/en/connector-jトラブルシューティングの章の-usagenotes-troubleshooting.html#qandaitem-15-1-4)をご覧ください)。少なくとも[2004](https://bugs.mysql.com/bug.php?id=5020)以降です。 – vilpan

関連する問題