当前位置 : 首页 » 文章分类 :  开发  »  HikariCP

HikariCP

Hikari 光 数据库连接池 笔记

brettwooldridge/HikariCP
https://github.com/brettwooldridge/HikariCP

Spring Boot在2.0版本中把 HikariCP 作为其默认的JDBC连接池。

Springboot 2.0选择HikariCP作为默认数据库连接池的五大理由
http://blog.didispace.com/Springboot-2-0-HikariCP-default-reason/


数据库连接池大小设置

【追光者系列】Hikari连接池大小多大合适?(第一弹)
https://juejin.im/post/5ad44c9b6fb9a028d70112e0

【追光者系列】Hikari连接池大小多大合适?(第二弹)
https://juejin.im/post/5ad44d716fb9a028bd4cc8f7

connectionTimeout:300000

从连接池获取可用连接的超时时间
最小值 250 ms,默认值 300000 ms(30秒)
假如此时间内没有获取到可用连接则抛出 java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms. 异常


CannotGetJdbcConnectionException

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 java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
### The error may exist in com/common/mapper/BaseAccountInfoMapper.java (best guess)
### The error may involve com.common.mapper.BaseAccountInfoMapper.queryUserIdByAccountId
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79) ~[mybatis-spring-1.3.0.jar!/:1.3.0]
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) ~[mybatis-spring-1.3.0.jar!/:1.3.0]
        at com.sun.proxy.$Proxy130.selectOne(Unknown Source) ~[?:?]
        at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:167) ~[mybatis-spring-1.3.0.jar!/:1.3.0]
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) ~[mybatis-3.4.0.jar!/:3.4.0]
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.0.jar!/:3.4.0]
        at com.sun.proxy.$Proxy137.queryUserIdByAccountId(Unknown Source) ~[?:?]

原因是 hikari 连接池中连接都已被占用,获取不到可用的 jdbc 连接,等待一段时间后超时。


上一篇 Vue

下一篇 Raft分布式一致性算法

阅读
评论
424
阅读预计2分钟
创建日期 2019-05-21
修改日期 2019-09-26
类别

页面信息

location:
protocol:
host:
hostname:
origin:
pathname:
href:
document:
referrer:
navigator:
platform:
userAgent:

评论