解决mysql中数据库连接connection holder is null的问题

一。问题

频繁查询或者更新数据库时,出现以下问题报错:

Cause: java.sql.SQLException: connection holder is null
在这里插入图片描述

二。解决方法

在application.xml配置文件中加入以下配置:

spring:
  datasource:
    # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
    timeBetweenEvictionRunsMillis: 60000
    #是否自动回收超时连接
    removeAbandoned: true
    #超时时间(以秒数为单位)
    removeAbandonedTimeout: 1800

配置间隔多久才进行一次检测需要关闭的空闲连接,加大超时时间以及是否自动回收超时连接:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44009447/article/details/113417028