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

相关推荐
无边风月-风之羽翼2 小时前
【自记录】Ubuntu20.04下Python自编译
开发语言·python
菜鸟康3 小时前
手写Muduo网络库核心代码2--Poller、EPollPoller详细讲解
开发语言·网络·php
秋风&萧瑟3 小时前
【QT】Qt QSS 中 background-image、image 和 border-image 的区别
开发语言·qt
学生董格3 小时前
[嵌入式embed][Qt]Qt5.12+Opencv4.x+Cmake4.x_测试Qt编译的opencv4.x的库
开发语言·qt
辗转反侧着疑惑3 小时前
MyBatis Plus 【详解】| 学习日志 | 第 17 天
java·开发语言·学习·mybatis·mybatis-plus
David爱编程3 小时前
对象锁 vs 类锁:Java 并发中的隐形对决
java·后端
Joy-鬼魅3 小时前
在 Qt 的 .pro 文件中设置警告级别和 C++11 标准
开发语言·c++·qt
脑子慢且灵4 小时前
【Web前端】JS+DOM来实现乌龟追兔子小游戏
java·开发语言·前端·js·dom
ytadpole4 小时前
揭秘设计模式:优雅地为复杂对象结构增添新功能-访问者模式
java·设计模式