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

相关推荐
hello_2504 分钟前
k8s安全机制解析:RBAC、Service Account与安全上下文
java·安全·kubernetes
望获linux42 分钟前
【实时Linux实战系列】实时安全 C++ 模式:无异常、预分配与自定义分配器
java·linux·服务器·开发语言·数据库·chrome·tomcat
码猩42 分钟前
wordVSTO插件实现自动填充序号
开发语言·c#
多多*1 小时前
linux安装hbase(完)
java·分布式·算法·c#·wpf
野木香1 小时前
tdengine笔记
开发语言·前端·javascript
new_daimond1 小时前
设计模式-享元模式详解
java·设计模式·享元模式
雪域迷影2 小时前
使用C++编写的一款射击五彩敌人的游戏
开发语言·c++·游戏
郝学胜-神的一滴2 小时前
享元模式(Flyweight Pattern)
开发语言·前端·c++·设计模式·软件工程·享元模式
软件柠檬2 小时前
Java中Integer是如何应用享元模式的?
java·享元模式
Taylor不想被展开2 小时前
SpringBoot 项目集成 Flyway
java·spring boot·mysql