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 分钟前
个人博客|博客app|基于Springboot+微信小程序的个人博客app系统设计与实现(源码+数据库+文档)
java·前端·数据库·spring boot·后端·小程序·论文
曹绍华9 分钟前
android 线程loop
android·java·开发语言
我命由我1234514 分钟前
Android 开发 - Android JNI 开发关键要点
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
树在风中摇曳17 分钟前
C语言动态内存管理:从基础到进阶的完整解析
c语言·开发语言·算法
YG亲测源码屋27 分钟前
怎么让自己的网址被百度收录(网站如何被百度收录进去)
java·百度·dubbo
风筝在晴天搁浅28 分钟前
代码随想录 Q89.跳跃游戏Ⅱ
java
mjhcsp30 分钟前
C++ 高精度计算:突破数据类型限制的实现与应用
开发语言·c++·算法·高精度
lixinnnn.31 分钟前
C++: map和set
开发语言·c++
郝学胜-神的一滴1 小时前
Qt QPushButton 样式完全指南:从基础到高级实现
linux·开发语言·c++·qt·程序人生
沐知全栈开发1 小时前
R MySQL 连接
开发语言