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);
相关推荐
橙露1 小时前
Spring Boot 核心原理:自动配置机制与自定义 Starter 开发
java·数据库·spring boot
冰暮流星1 小时前
sql语言之分组语句group by
java·数据库·sql
符哥20081 小时前
Ubuntu 常用指令集大全(附实操实例)
数据库·ubuntu·postgresql
筵陌1 小时前
MySQL索引及其底层原理(上)
mysql
C++ 老炮儿的技术栈1 小时前
Qt 编写 TcpClient 程序 详细步骤
c语言·开发语言·数据库·c++·qt·算法
怣501 小时前
MySQL子查询零基础入门教程:从小白到上手(零基础入门版)
数据库·mysql
码界调试侠1 小时前
MongoDB 常用查询语法
数据库·mongodb
静听山水2 小时前
StarRocks导入数据【Stream Load】
数据库
藦卡机器人2 小时前
国产机械臂做的比较好的品牌有哪些?
大数据·数据库·人工智能
jiunian_cn2 小时前
【Redis】数据库管理操作
数据库·redis·缓存