mysql、postgresql、druid链接池踩坑记录

The last packet successfully received from the server wIs 10,010 milliseconds ago. The last packet sent successfully to the server was 10,010 milliseconds ago.### The error may exist in URL

mysql 链接字符串没有 &connectTimeout=600000&socketTimeout=600000 导致查询超过10秒就报错了

org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.

postgresql是同样的问题,报错不一样,也是10秒超时。postgresql链接字符串加了&connectTimeout=600000&socketTimeout=600000这个不生效。发现druid这个玩意也是个坑

复制代码
不管datasource.setSocketTimeout()给多少值根本就不生效 在datasource.getConnection()的时候就会更新成 10000 

最后用 HikariDataSource就没问题。

复制代码
HikariConfig config = new HikariConfig();
            config .setJdbcUrl(url);
            config .setUsername(username);
            config .setPassword(password);
            config .setDriverClassName(driverClass);

            // 设置连接池属性
            config.setMaximumPoolSize(10);
            config.setMinimumIdle(5);
            config.setIdleTimeout(30000);

            return new HikariDataSource(config);
相关推荐
Ctrl+S 之后6 小时前
分布式数据库高可用架构设计与动态一致性优化实践经验分享
数据库·经验分享·分布式
沐浴露z8 小时前
详解 MySQL 自适应哈希
数据库·mysql·哈希算法
小五Z8 小时前
MySQL--事务
数据库·mysql
小许学java8 小时前
MySQL存储过程
数据库·mysql·存储过程
Elias不吃糖9 小时前
MYSQL指令合集
数据库·mysql
!chen11 小时前
解决 Oracle 监听外网 IP
数据库·tcp/ip·oracle
LBuffer12 小时前
破解入门学习笔记题四十六
数据库·笔记·学习
chase。12 小时前
关于 nvidia-smi: no devices were found 解决方案
服务器·数据库·postgresql
几何心凉12 小时前
openGauss:多核时代企业级数据库的性能与高可用新标杆
前端·数据库·数据库开发
q***040513 小时前
在 Ubuntu 上安装 MySQL 的详细指南
mysql·ubuntu·adb