Caused by: java.net.SocketTimeoutException: Read timed out;

Cause: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.; An I/O error occurred while sending to the backend.; nested exception is org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.

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

Caused by: java.net.SocketTimeoutException: Read timed out;

最近在做一个复杂查询,数据量比较大,需要二十多秒才能返回得结果,提交了请求之后还没等结果吐出来就报错了,发现是因为没有添加超时配置,所以在查询又或者读取的时候超时了,我这里是读取的时候超时了,既然超时了直接把超时时间延长就好了,我用的是druid(德鲁伊)

在数据库url补上两个参数 socketTimeout=300000&loginTimeout=60000

spring:

datasource:

url: jdbc:postgresql://localhost:3306/yourdb?socketTimeout=300000&loginTimeout=60000

或者

connection-timeout: 60000 # 建立连接超时:60秒

socket-timeout: 300000 # Socket读取超时:5分钟

query-timeout: 180000 # 查询执行超时:3分钟

相关推荐
南 阳9 分钟前
Python从入门到精通day56
开发语言·python
xiaohe0713 分钟前
Maven Spring框架依赖包
java·spring·maven
m0_5698814716 分钟前
C++中的组合模式高级应用
开发语言·c++·算法
m0_7301151120 分钟前
高性能计算负载均衡
开发语言·c++·算法
孞㐑¥28 分钟前
算法—记忆化搜索
开发语言·c++·经验分享·笔记·算法
xushichao198929 分钟前
代码覆盖率工具实战
开发语言·c++·算法
2401_8579182931 分钟前
C++与WebAssembly集成
开发语言·c++·算法
hssfscv31 分钟前
软件设计师下午题二 E-R图
java·笔记·学习
2401_8796938731 分钟前
C++与微服务架构
开发语言·c++·算法
阿kun要赚马内32 分钟前
Python中函数的进阶用法
开发语言·python