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

相关推荐
Tony Bai1 小时前
“我曾想付钱给 Google 去工作”—— Russ Cox 深度访谈:Go 的诞生、演进与未来
开发语言·后端·golang
sali-tec1 小时前
C# 基于halcon的视觉工作流-章66 四目匹配
开发语言·人工智能·数码相机·算法·计算机视觉·c#
45288655上山打老虎1 小时前
C++完美转发
java·jvm·c++
Seven972 小时前
查找算法
java
hnlgzb2 小时前
安卓app开发,如何快速上手kotlin和compose的开发?
android·开发语言·kotlin
无敌最俊朗@2 小时前
STL-deque面试剖析(面试复习4)
开发语言
APIshop2 小时前
用 Python 把“API 接口”当数据源——从找口子到落库的全流程实战
开发语言·python
毕设源码-朱学姐3 小时前
【开题答辩全过程】以 公务员考试在线测试系统为例,包含答辩的问题和答案
java
serendipity_hky3 小时前
【SpringCloud | 第2篇】OpenFeign远程调用
java·后端·spring·spring cloud·openfeign
Java Fans3 小时前
Qt Designer 和 PyQt 开发教程
开发语言·qt·pyqt