mysql 报错:Can not read response from server. Expected to read 4 bytes, read 0 bytes be

记录最近开发遇到一个这样的错误,Can not read response from server. Expected to read 4 bytes, read 0 bytes be,执行出错的第三是在定时任务,3秒一次执行,查询数据库的时候抛的错误

经过网上一堆查询资料后原因:使用的连接池,连接池里的链接已经关闭了,但是连接池未次此链接已关闭,仍然去执行sql,结果导致错误。

抱着试一试的心态,加上了一个验证链接的sql

基于springboot的项目,截图如下:

问题得到解决。

猜你喜欢

转载自blog.csdn.net/q1035331653/article/details/116936877