MySQLNonTransientConnectionException: No operations allowed after connection closed.

MySQL数据库异常


ssm 框架 jdbc连接数据库出现如下异常:

异常描述:

Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

大致原因:

数据库连接池超过8小时未响应,则自动断开连接。数据库连接关闭后不允许操作。

采取措施:

出处 : https://blog.csdn.net/u010711754/article/details/79418069

 

修改 mysql 数据库的配置文件

修改my.cnf:

[mysqld]

wait_timeout=31536000

interactive_timeout=31536000

将过期时间修改为1年。

 

在项目的配置文件 dbcp 配置文件中(当前项目为db.properties)

在连接URL后追加参数:&autoReconnect=true&failOverReadOnly=false

 

重启数据库 

# service mysqld restart

 

修复结果待验证.......

猜你喜欢

转载自blog.csdn.net/ningwb______/article/details/88420136