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分钟

相关推荐
CC.GG1 分钟前
【C++】C++11(二)可变模板参数模板、新的类功能、包装器(function、bind)
开发语言·c++
Sanyhem2 分钟前
2025 年高频考点与深度追问点
java·面试
摇滚侠4 分钟前
解决 IntelliJ IDEA 中 Maven 管理界面不是层级结构的问题
java·maven·intellij-idea
Mr Aokey7 分钟前
RabbitMQ进阶实战:三种典型消息路由模式详解(订阅/路由/主题)
java·网络·rabbitmq
Yupureki10 分钟前
《算法竞赛从入门到国奖》算法基础:入门篇-分治
c语言·开发语言·数据结构·c++·算法·贪心算法
无心水13 分钟前
4、Go语言程序实体详解:变量声明与常量应用【初学者指南】
java·服务器·开发语言·人工智能·python·golang·go
ZPC821014 分钟前
psutil
开发语言·php
jiunian_cn15 分钟前
【C++】线程库
开发语言·c++
sheji341615 分钟前
【开题答辩全过程】以 食堂兼职管理系统为例,包含答辩的问题和答案
java·eclipse
0x5315 分钟前
JAVA|智能仿真并发项目-并行与并发
java·开发语言