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

相关推荐
侠客行031714 小时前
Mybatis连接池实现及池化模式
java·mybatis·源码阅读
蛇皮划水怪14 小时前
深入浅出LangChain4J
java·langchain·llm
灰子学技术15 小时前
go response.Body.close()导致连接异常处理
开发语言·后端·golang
老毛肚15 小时前
MyBatis体系结构与工作原理 上篇
java·mybatis
风流倜傥唐伯虎16 小时前
Spring Boot Jar包生产级启停脚本
java·运维·spring boot
二十雨辰16 小时前
[python]-AI大模型
开发语言·人工智能·python
Yvonne爱编码16 小时前
JAVA数据结构 DAY6-栈和队列
java·开发语言·数据结构·python
Re.不晚16 小时前
JAVA进阶之路——无奖问答挑战1
java·开发语言
你这个代码我看不懂16 小时前
@ConditionalOnProperty不直接使用松绑定规则
java·开发语言
pas13616 小时前
41-parse的实现原理&有限状态机
开发语言·前端·javascript