mysql连接异常-CommunicationException

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhang_jian__/article/details/82180113

今天遇到上图的异常。

原因:mysql连接在超过空闲连接超时时间后被断开,此时程序不知道该连接已经断开,继续使用就会报上图的错。

解决办法:一般情况下很少出现这种错误。解决方法有多种,可以从数据库层面解决:将过期时间设置成很大,不让连接超时;也可以从程序层面解决,在使用连接前校验有效性。

具体可以参考:https://blog.csdn.net/shiqidide/article/details/7642531http://blog.sina.com.cn/s/blog_4f925fc30102v611.html

猜你喜欢

转载自blog.csdn.net/zhang_jian__/article/details/82180113