由于本人测试插入语句时,连接的是外网数据库时出现这个问题

No operations allowed after statement closed.(语句关闭后不允许进行任何操作)
Mybatis插入数据时出现No operations allowed after statement closed._外网

原因:

Mysql在5以后针对超长时间DB连接做了一个处理,当连接时长超过"wait_timeout"设置的时间会断开连接,所以使用连接池的时候虽然连接对象还在但是链接数据库的时候会一直报这个异常.

解决方法:

通过语句查看"wait_timeout"的时长:

show global variables like ‘wait_timeout’;

Mybatis插入数据时出现No operations allowed after statement closed._外网_02
增加MySQL的 wait_timeout 的时间:
windows环境下:,修改mysql5的配置文件“my.ini”(mysql5 installation dir),增加一行:wait_timeout=1814400 (修改时间为21天)
Linux下:叫my.cnf,该文件位于/etc/my.cnf
或者,登录MySQL,使用SQL语句修改,set global wait_timeout=1000000;
Mybatis插入数据时出现No operations allowed after statement closed._sql_03