数据库连接超时Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

错误分析:

     数据库连接已经关闭或者失效后仍然在执行操作,导致:mysql服务没返回数据

     1.客户端连接池中连接,已经失效;但是:连接池还没有检测到;当操作数据库时,启用该连接,抛出该错误

     2.mysql服务器,已关闭该连接,但:客户端连接池中该连接,尚未检测到。当用该连接操作数据库时,抛出该错。



处理办法:

     1.每次连接操作数据库时,检测:该连接的有效性

    <property name=”minEvictableIdleTimeMillis” value=”1800000″ />
    <property name=”numTestsPerEvictionRun” value=”3″ />
    <property name=”testOnBorrow” value=”true” />
    <property name=”testWhileIdle” value=”true” />
    <property name=”testOnReturn” value=”true” />
    <property name=”validationQuery” value=”SELECT 1″ />


     2.缩短监控空闲线程的时间。

 

posted @ 2020-05-14 10:01  kingdaqi  阅读(16382)  评论(0编辑  收藏  举报