日志报错:
No operations allowed after connection closed.; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
解决办法:
对数据库进行如下配置即可:
dataSource.setTimeBetweenEvictionRunsMillis(3600000);
dataSource.setTestWhileIdle(true);
dataSource.setValidationQuery("select 1");
dataSource.setTestOnBorrow(false);
- timeBetweenEvictionRunsMillis:失效检查线程运行时间间隔,如果小于等于0,不会启动检查线程,默认-1
- testOnBorrow:取得对象时是否进行验证,检查对象是否有效,默认为false
- testWhileIdle:空闲时是否进行验证,检查对象是否有效,默认为false
- validationQuery: 验证连接是否成功, SQL SELECT 指令至少要返回一行