mysql 超时配置

日志报错:

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 指令至少要返回一行

mysql 超时配置

上一篇:oracle报无效日期(针对timeStamp)


下一篇:ORACLE SYS_REFCURSOR VS REF CURSOR