HikariCP自动重新连接

编程入门 行业动态 更新时间:2024-10-24 10:21:57
本文介绍了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自动重新连接

本文发布于:2023-11-05 04:53:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:HikariCP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!