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);
相关推荐
龙仔7252 小时前
人大金仓OS_Core数据库自动备份实施笔记(银河麒麟Linux)
linux·数据库·笔记·备份·人大金仓
老杨聊技术2 小时前
CentOS 7 安装 MySQL 8 保姆级教程
linux·mysql·centos
sunxr.2272 小时前
Mysql-----最后一次作业
数据库·mysql
普通网友2 小时前
Python FastAPI 异步数据库管理
数据库·fastapi
晓子文集2 小时前
Tushare接口文档:期货合约信息表(fut_basic)
大数据·数据库·金融·金融数据·量化投资
三言老师3 小时前
CentOS7.9:Redis‑Cluster集群部署结构化实战教程
linux·运维·服务器·数据库
旺仔学长 哈哈4 小时前
Spring Boot 智能停车场管理系统---附源码+数据库文档
数据库·spring boot·后端·智能停车场
ClickHouseDB4 小时前
ClickHouse托管Postgres:OLTP+OLAP,新能力解锁最佳数据平台
java·前端·数据库
数智化管理手记4 小时前
主数据重复、错漏频发?一站式主数据管理平台如何落地?
大数据·运维·数据库·人工智能·数据挖掘
吴声子夜歌5 小时前
MongoDB 4.2——选择片键
数据库·mongodb