hibernate -- 数据库连接池的失效检查设置

<property name="testOnBorrow" value="true"/> <!--  数据库连接池中取得连接时,对其的有效性进行检查 ,会影响一定性能--> 
      <property name="testWhileIdle" value="true"/> <!--异步Evict的TimerTask定时线程进行控制  定时对线程池中的链接进行validateObject校验--> 
      <property name="timeBetweenEvictionRunsMillis" value="25200000"/><!--失效检查线程运行时间间隔(毫米) 大于0才会开启evict检查线程--> 
      <property name="validationQuery" value="select 1"/> <!-- 校验sql-->

  注:mysql是默认8小时释放连接,若不进行失效检查,会出现数据库无法连接的Socket异常

原文地址:https://www.cnblogs.com/tongxinyuan/p/4481365.html