一、異常截圖
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的時間限制