我有一個與MySQL DB交互的Java web應用程序。我從不關閉數據庫連接,並使用單例來處理連接實例。MySQL連接不見了Java
的問題是,我保持連接後打開太久,我嘗試做在應用中的一些動作,我收到此錯誤:
The last packet successfully received from the server was 211,710,369 milliseconds ago. The last packet sent successfully to the server was 211,710,398 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.
任何想法,我怎麼能做出autoReconnect=true
?或者爲什麼會發生?我雖然會默認自動重新連接。還是應該在每次請求後關閉數據庫?這是降低性能這是至關重要的這個應用程序。
我可以提供更多信息嗎?
您是否真的讓連接閒置了2.45天? –
如果連接閒置2½天,則打開和關閉連接不會是性能問題。 –
經典。性能問題。 – Drew