当前位置:网站首页>解决数据库连接池HikariCP问题
解决数据库连接池HikariCP问题
2022-07-16 17:21:00 【arthur.dy.lee】
解决HikariCP的com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure的问题
om.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
servicename:bc-checkup message:2022-03-16 16:01:19.928 [Thread-42] WARN com.zaxxer.hikari.HikariConfig - HikariPool-38 - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool. fields.host:10.161.51.246 log_type:wallet-bc-dw host.name:ip-10-161-51-246.ap-southeast-1.compute.internal @version:1 @timestamp:Mar 16, 2022 @ 16:01:19.959 _id:Fhe-kX8BCBBWjK6M5MOX _type:doc _index:wallet-bc-dw-logs-2022.03.11 _score: -
配置以下参数
db-minimum-idle: 5
db-maximum-pool-size: 10
db-max-lifetime: 60000
db-idle-timeout: 60000
db-connection-timeout: 60000
db-validation-timeout: 3000
java代码
public class DatabaseSourceServiceImpl implements DatabaseSourceService, BeanFactoryAware {
@Value("${bc.mybatisplus.db-minimum-idle}")
private Integer minimumIdle;
@Value("${bc.mybatisplus.db-maximum-pool-size}")
private Integer maximumPoolSize;
@Value("${bc.mybatisplus.db-max-lifetime}")
private Integer maxLifetime;
@Value("${bc.mybatisplus.db-idle-timeout}")
private Integer idleTimeout;
@Value("${bc.mybatisplus.db-connection-timeout}")
private Integer connectionTimeout;
@Value("${bc.mybatisplus.db-validation-timeout}")
private Integer validationTimeout;
@Override public void addDataSource(String datasourceName) {
//.....
if (dbSource.getMinimumIdle() == null || dbSource.getMinimumIdle().intValue() <= 0) {
dbSource.setMinimumIdle(minimumIdle); //从nacos取
}
configuration.setMinimumIdle(dbSource.getMinimumIdle());
if (dbSource.getMaximumPoolSize() == null || dbSource.getMaximumPoolSize() <= 0) {
dbSource.setMaximumPoolSize(maximumPoolSize); //从nacos取
}
configuration.setMaximumPoolSize(dbSource.getMaximumPoolSize());
if (dbSource.getMaxLifetime() == null || dbSource.getMaxLifetime() <= 0) {
dbSource.setMaxLifetime(maxLifetime);
}
configuration.setMaxLifetime(dbSource.getMaxLifetime());
if (dbSource.getIdleTimeout() == null || dbSource.getIdleTimeout() <= 0) {
dbSource.setIdleTimeout(idleTimeout);
}
configuration.setIdleTimeout(dbSource.getIdleTimeout());
if (dbSource.getConnectionTimeout() == null || dbSource.getConnectionTimeout() <= 0) {
dbSource.setConnectionTimeout(connectionTimeout);
}
configuration.setConnectionTimeout(dbSource.getConnectionTimeout());
configuration.setConnectionTestQuery("SELECT 1");
configuration.setValidationTimeout(validationTimeout);
configuration.setAllowPoolSuspension(true);
//configuration.setRegisterMbeans(true);
configuration.setPoolName(datasourceName + "-Hikari-POOL");
HikariDataSource dataSource = new HikariDataSource(configuration);
try {
dataSource.setLoginTimeout(5);
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
//....
}
}
边栏推荐
- MySQL中 8 种常见的 SQL 错误用法
- Processing numbers are expressed in Chinese
- [chance enlightenment -45]: Guiguzi - Chapter 9 - because people talk, like them
- Nc20566 [scoi2010] games
- Trapped in the marketing siege, how long can Hua Xizi bear the title of "light of domestic goods"?
- 阿里云视频点播
- Liu tiemeng's introduction to C language - detailed explanation of entrustment
- feign调用传递请求头
- 【uniapp-checkbox】修改uniapp-checkbox复选框的样式
- Add, delete, check and modify the MySQL Learning Notes database (Advanced)
猜你喜欢
![[C language] in depth understanding of conditional compilation](/img/5e/721d35938179ff59c5eb91c9a31794.jpg)
[C language] in depth understanding of conditional compilation
![[leetcode] sword finger offer 39 Numbers that appear more than half of the time in the array](/img/8e/7accdb74233258598cab0e27dd50d1.png)
[leetcode] sword finger offer 39 Numbers that appear more than half of the time in the array

The first large-scale Chinese video multimodal similarity data set

【C语言】条件编译的深入理解

go ———数组与切片的区别

Test management knowledge: how to transform from a business expert to a grass-roots Manager

2022 年度杭州未来科技城数字经济人才编程大赛

Codeforces Round #805 (Div. 3)(A,B,C,D)

一场羽绒服直播GMV狂涨430%,反季热销的秘诀原来是这个?

Taote commodity details API interface (commodity sales interface, commodity price sorting interface, repeat customers often buy interface, APP commodity details interface, commodity attribute interfac
随机推荐
最近發現了動畫庫 lottie
一场羽绒服直播GMV狂涨430%,反季热销的秘诀原来是这个?
【学浪下载教程】05学浪下载之正式抓包下载
One of building PSIM simulation model of buck circuit (stability analysis of PI module)
OpenGL es learning (2) -- vertex shaders and slice shaders
【word】公式排版问题
[leetcode] sword finger offer 50 The first character that appears only once
1. Self made script language - Chapter 1 Notes
1.4.2-sql injection defense bypass - Secondary encoding injection
【机器视觉】Canny边缘检测MATLAB源码阅读
支付流程面试思路
长安链tls基础研究
MultipartFile与base64互转
MySQL 66 questions, 20000 words + 50 pictures in detail! A little six!
Kernel management of Jupiter notebook
【C语言】条件编译的深入理解
【剑指 Offer II 041. 滑动窗口的平均值】
淘特商品详情API接口(商品销量接口,商品价格排序接口,回头客常买接口,APP商品详情接口,商品属性接口)
Network disk + download method of the first nuscenes dataset in the whole network
Fade in and fade out 1920-500 (8)