求救:项目急到交付,在大量查询数据库的时候,提示异常获取不到数据库连接。 · 物联网平台-威尼斯人最新

lifeontrip · 2020年03月06日 · 最后由 回复于 2022年09月03日 · 543 次阅读

### 异常信息 ###

2020-03-06 20:35:02,362 debug (org.mybatis.spring.sqlsessionutils:140) - sqlsession [org.apache.ibatis.session.defaults.defaultsqlsession@59754bb] was not registered for synchronization because synchronization is not active
2020-03-06 20:35:23,377 debug (org.mybatis.spring.sqlsessionutils:168) - closing non transactional sqlsession [org.apache.ibatis.session.defaults.defaultsqlsession@59754bb]
org.mybatis.spring.mybatissystemexception: nested exception is org.apache.ibatis.exceptions.persistenceexception: 
### error querying database.  cause: org.springframework.jdbc.cannotgetjdbcconnectionexception: could not get jdbc connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.communicationsexception: communications link failure
the last packet sent successfully to the server was 0 milliseconds ago. the driver has not received any packets from the server.
### the error may exist in file [w:\ny_machinejob\nongji\target\nongji-0.1-snapshot\web-inf\classes\com\nongji\mapping\usermapper.xml]
### the error may involve com.nongji.dao.userdao.getinfolist
### the error occurred while executing a query
### cause: org.springframework.jdbc.cannotgetjdbcconnectionexception: could not get jdbc connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.communicationsexception: communications link failure
the last packet sent successfully to the server was 0 milliseconds ago. the driver has not received any packets from the server.
    at org.mybatis.spring.mybatisexceptiontranslator.translateexceptionifpossible(mybatisexceptiontranslator.java:75)
    at org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke(sqlsessiontemplate.java:371)
    at com.sun.proxy.$proxy19.selectlist(unknown source)
    at org.mybatis.spring.sqlsessiontemplate.selectlist(sqlsessiontemplate.java:198)
    at org.apache.ibatis.binding.mappermethod.executeformany(mappermethod.java:119)
    at org.apache.ibatis.binding.mappermethod.execute(mappermethod.java:63)
    at org.apache.ibatis.binding.mapperproxy.invoke(mapperproxy.java:52)
    at com.sun.proxy.$proxy22.getinfolist(unknown source)

### 数据库连接池的配置 ###


#初始化连接
jdbc.initialsize=10
#最大连接数量
jdbc.maxactive=50
#最大空闲连接
jdbc.maxidle=20
#最小空闲连接
jdbc.minidle=5
#大于0 ,进行连接空闲时间判断,或为0,对空闲的连接不进行验证;默认30分钟 (毫秒)
jdbc.minevictableidletimemillis=1800000
#超时等待时间以毫秒为单位
#maxwait代表当connection用尽了,多久之后进行回收丢失连接
jdbc.maxwait=3000
#空闲时是否进行验证,检查对象是否有效,默认为false
jdbc.testwhileidle=true
#失效检查线程运行时间间隔,如果小于等于0,不会启动检查线程 (毫秒)
jdbc.timebetweenevictionrunsmillis=60000
#是否在自动回收超时连接的时候打印连接的超时错误
#jdbc.logabandoned=true
#是否自动回收超时连接
jdbc.removeabandoned=true
#超时时间(以秒数为单位)
#设置超时时间有一个要注意的地方,超时时间=现在的时间-程序中创建connection的时间,如果 maxactive比较大,比如超过100,那么removeabandonedtimeout可以设置长一点比如180,也就是三分钟无响应的连接进行 回收,当然应用的不同设置长度也不同。
jdbc.removeabandonedtimeout=180
#打开pscache,并且指定每个连接上pscache的大小
jdbc.maxpoolpreparedstatementperconnectionsize=20
jdbc.poolpreparedstatements=true
#配置监控统计拦截的filters
jdbc.filters=slf4j

#取得对象时是否进行验证,检查对象是否有效,默认为false
jdbc.testonborrow=true
#验证连接是否有效的sql文
jdbc.validationquery=select 1
#执行验证连接有效sql文的超时时间
jdbc.validationquerytimeout=100
#返回对象时是否进行验证,检查对象是否有效,默认为false
jdbc.testonreturn=false

项目是 spring boot 开发的,请大神帮忙看下问题在哪里,想个可行的澳门人威尼斯3966的解决方案!

最大连接数量 : jdbc.maxactive=0

将 maxactivie 设置为 0。不限制数据库的最大链接数。可以避免高并发查询时出现无法获取数据库连接的问题。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
网站地图