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);
相关推荐
m0_748246873 小时前
MySQL8.0 innodb Cluster 高可用集群部署(MySQL、MySQL Shell、MySQL Router安装)
android·mysql·adb
一张假钞3 小时前
Python3操作MongoDB批量upsert
开发语言·数据库·python·mongodb
Beronhider3 小时前
SQLZoo-SELECT within SELECT Tutorial
数据库·sql·mysql·数据分析
atom goper4 小时前
Redis混合持久化
数据库·redis·mybatis
yqcoder4 小时前
MongoDB 的基本概念
数据库·mongodb
JavaGuide5 小时前
Spring 项目接入 DeepSeek,分享两种超简单的方式!
数据库·python·spring
Minxinbb6 小时前
MySQL 中可以通过添加主键来节省磁盘空间吗?(译文)
数据库·mysql·dba
qq_13948428826 小时前
springboot239-springboot在线医疗问答平台(源码+论文+PPT+部署讲解等)
java·数据库·spring boot·后端·spring·maven·intellij-idea
神仙别闹6 小时前
基于Springmvc+MyBatis+Spring+Bootstrap+EasyUI+Mysql的个人博客系统
java·mysql·ssm
陈老师还在写代码7 小时前
讲解下MySql的外连接查询在SpringBoot中的使用情况
数据库·spring boot·mysql