2013-08-02 50 views
0

在我的prod服務器上獲得以下異常,但幾小時後會自動解析。可能是什麼原因這個問題引起:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was234747 milliseconds ago.The last packet sent successfully to the server was 234747 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. 

我們已經成立autoReconnect的=真已,從論壇我發現,我們需要使空閒連接測試。請告知

它會在應用程序中導致此異常的任何未關閉連接嗎?

我們使用iBATIS以下是Ibatisconfig文件

<transactionManager type="JDBC" commitRequired="true"> 
    <dataSource type="SIMPLE"> 
     <property name="JDBC.Driver" value="com.mysql.jdbc.Driver" /> 
     <property name="JDBC.ConnectionURL" 
      value="<URL>?autoReconnect=true" /> 
     <property name="JDBC.Username" value="<username>" /> 
     <property name="JDBC.Password" value="<password>" /> 
     <property name="JDBC.DefaultAutoCommit" value="false" /> 
     <property name="Pool.TimeToWait" value="100" /> 
     <property name="Pool.PingQuery" value="select 1" /> 
     <property name="Pool.PingEnabled" value="true" /> 
     <property name="Pool.PingConnectionsOlderThan" value="300000" /> 
     <property name="Pool.PingConnectionsNotUsedFor" value="300000" /> 
    </dataSource> 
</transactionManager> 
+0

你檢查了你的SQL服務器日誌嗎?可能相關的SO線程:http://stackoverflow.com/questions/1511855/reproduce-com-mysql-jdbc-exceptions-jdbc4-communicationsexception-with-a-setup-o和http://stackoverflow.com/questions/9527459/com-mysql-jdbc-exceptions-jdbc4-communicationsexception -communications-link-fai – rutter

回答

1

嗯,在我的項目,我遇到了同樣的問題。我們使用mysql,如果連接閒置了8個小時,那麼db就不可用。我們使用的解決方案是使用C3P0連接池。在這裏檢查一下。 http://www.mchange.com/projects/c3p0/

+0

他們是否有Ibatis的選項,我聽說過它的休眠 –

+0

我們以前從未使用過Ibatis。閱讀你的評論後,我搜索了一下,我發現了一篇文章。希望這會幫助你.http://www.opendebug.com/article/447235 – chaitanya89

相關問題