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);
相关推荐
冉冰学姐12 小时前
SSM公办小学网络报名系统f3d3p(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·ssm 框架·公办小学网络报名系统·教育信息化
叡鳍12 小时前
hive---HQL查询
数据库
vortex513 小时前
谷歌黑客语法挖掘 SQL 注入漏洞
android·数据库·sql
九河云13 小时前
软件开发平台 DevCloud
运维·服务器·数据库·科技·华为云
wind_one114 小时前
7.基础--SQL--DDL-数据类型及案例
数据库·sql
l1t15 小时前
利用DeepSeek改写SQLite版本的二进制位数独求解SQL
数据库·人工智能·sql·sqlite
QT 小鲜肉15 小时前
【QT/C++】Qt定时器QTimer类的实现方法详解(超详细)
开发语言·数据库·c++·笔记·qt·学习
研究司马懿15 小时前
【ETCD】ETCD常用命令
网络·数据库·云原生·oracle·自动化·运维开发·etcd
-指短琴长-16 小时前
MySQL快速入门——基本查询(下)
android·mysql·adb
刘一说16 小时前
深入理解 Spring Boot 中的数据库迁移:Flyway 与 Liquibase 实战指南
数据库·spring boot·oracle