您的位置:首页 > 产品设计 > UI/UE

解决MySQL连接超时Communications link failure due to underlying exception

2013-03-05 12:59 696 查看



最近在用一个MySQL的Java连接池的过程中,连接一晚上不释放,第二天就会造成超时的错误,查了一下原因,原来是因为MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常。异常文本如下:

com.mysql.jdbc.CommunicationsException

MESSAGE: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException

MESSAGE: Software caused connection abort: socket write error

解决方式:编辑/etc/mysqlmy.cnf(windows下为my.ini),将超时时间设置为10年,在[mysqld]后面加入:

wait_timeout=315360000

interactive_timeout=315360000

两句话都要写

然后重启MySQL

# service mysql restart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐