我使用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自动重新连接
发布评论