Flink程序異常--CommunicationsException: The last packet successfully received from the server was


一、異常截圖

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 46,912,998 milliseconds ago.  The last packet sent successfully to the server was 46,913,003 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.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

二、原因

連接數據庫超時

 

三、解決方法

解決方法1:使用連接池定時刷新服務器時間戳

解決方法2:flink連接mysql時指定autoReconnect=true

即使在創建Mysql時url中加入了autoReconnect=true參數,一但這個連接兩次訪問數據庫的時間超出了服務器端 wait_timeout的時間限制


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM