-java7
-tomcat7
-mybatis(ORM)
でwebサービスを開発しております。
予期せぬタイミングでMysqlのコネクションが切れて、ログアウト状態になり困っています。
その際にサーバーログを見てみると以下の様なエラーメッセージが出力されていました。
lang
1 2015 10:03:49 org.apache.ibatis.datasource.pooled.PooledDataSource warn 2 WARN: Execution of ping query 'SELECT 1' failed: Communications link failure 3 4 The last packet successfully received from the server was 30,572,290 milliseconds ago. The last packet sent successfully to the server was 1 milliseconds ago. 5 org.apache.ibatis.exceptions.PersistenceException: 6 ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,001,604 milliseconds ago. The last packet sent successfully to the server was 36,001,633 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 client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. 7 ### The error may exist in sql.xml 8 ### The error may involve com.xxx.isRegistered-Inline 9 ### The error occurred while setting parameters 10 ### SQL: [query for login]; 11 ### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 36,001,604 milliseconds ago. The last packet sent successfully to the server was 36,001,633 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 client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
mysqlの設定はすべてデフォルトなのでタイムアウトの時間はinteractive_timeout:28800(8時間)です。
8時間以内にアクセスしても一旦ログアウトされる現象がたびたび起きています。
poolPingQueryはMysqlのコネクションプールがアクティブかどうかを毎回測り,アクティブじゃなければ
このクエリによってアクティブにするような認識なのですが、以下のconfig設定でなにが悪いのかご教示ください。
エラーメッセージに書かれているautoReconnect=trueを接続URLの末尾にたしてもダメでした
config.xml
lang
1 <transactionManager type="JDBC" /> 2 <dataSource type="POOLED"> 3 <property name="driver" value="com.mysql.jdbc.Driver" /> 4 <property name="url" value="jdbc:mysql://localhost:3306/xxxxdb" /> 5 <property name="username" value="xxxxxxx" /> 6 <property name="password" value="xxxxxxx" /> 7 <property name="poolPingEnabled" value="true" /> 8 <property name="poolPingQuery" value="SELECT 1 " /> 9 </dataSource> 10 </environment>

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。