你用的flink哪个版本,flink-1.11已经加了连接失效重连的功能了,应该没有这个问题了。如果不是flink-1.11.x版本的,也可以参考flink-1.11的jdbc-connector的实现,或者用SELECT
 1 语句保活连接。
________________________________
发件人: 酷酷的浑蛋 <apach...@163.com>
发送时间: 2020年11月2日 2:28
收件人: user-zh@flink.apache.org <user-zh@flink.apache.org>
主题: Re:回复:flink1.11连接mysql问题

没有解决,隔一段时间就会报这个超时错误

















在 2020-10-14 17:33:30,"superainbower" <superainbo...@163.com> 写道:
>HI
>链接超时的问题,你后来解决了吗?能告诉下怎么解决的吗?
>| |
>superainbower
>|
>|
>superainbo...@163.com
>|
>签名由网易邮箱大师定制
>
>
>在2020年08月31日 15:57,酷酷的浑蛋<apach...@163.com> 写道:
>关键是在sql中怎么设置,connector=jdbc
>
>
>
>
>在2020年08月31日 15:06,13580506953<13580506...@163.com> 写道:
>这个问题本质是连接活性问题,
>连接数据库超时设置autoReconnect=true(mysql5以上的,设置autoReconnect=true 是无效的 只有4.x版本,起作用)
>
>
>建议使用连接池druid进行连接活性保持
>
>
>原始邮件
>发件人: 酷酷的浑蛋<apach...@163.com>
>收件人: user-zh<user-zh@flink.apache.org>
>发送时间: 2020年8月28日(周五) 15:02
>主题: flink1.11连接mysql问题
>
>
>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet 
>successfully received from the server was 52,445,041 milliseconds ago. The 
>last packet sent successfully to the server was 52,445,045 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, 
>orusing the Connector/J connection property 'autoReconnect=true' to avoid this 
>problem. flink连接mysql,在过了一定时间后,就断开连接了,设置'autoReconnect=true’也不管用

回复