数据库连接超时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.缩短监控空闲线程的时间。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM