HikariCP自动重新连接 [英] HikariCP auto reconnect

查看:3146
本文介绍了HikariCP自动重新连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jpa + hibernate + hikariCP。今天我收到连接关闭错误。我设置了 connectionTimeout ideleTimeout 属性(hikari)。如果在此期间使用不做任何操作hikari关闭池连接自动。所以我得到了关闭连接问题。我的问题如何设置正确的hiker(jpa,hibernate)属性,以便用户在3-4小时后回来并尝试做一些操作hikari自动重新连接到db?可能吗?
我使用hikari v2.6.1和hibernate v5.2.8.Final

I use jpa+hibernate+hikariCP. Today I got connection closed error. I setted connectionTimeout and ideleTimeout properties(hikari). If in meantime use does not do any operition hikari close the pool connections auto. So that I got closed connection problem. My question how can I set properly hiker(jpa,hibernate) properties so if user comes back after 3-4 hours and try to do some operation hikari auto reconnect to db? is it possible? I use hikari v2.6.1 and hibernate v5.2.8.Final

推荐答案

这应该已经有效了。你在这段时间里打开连接吗?默认情况下,HikariCP每30分钟关闭并更新一次连接(默认为maxLifetime)。如果您的数据库的空闲超时时间比此短,则需要调整HikariCP中的设置以匹配。

This should already be working. Are you holding the connection open during this time? By default HikariCP closes and renews connections every 30 minutes (maxLifetime default). If your database has a shorter idle timeout than that, then you need to adjust the setting in HikariCP to match.

这篇关于HikariCP自动重新连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆