Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariCP auto reconnect

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

like image 741
sancho Avatar asked Jul 27 '17 16:07

sancho


1 Answers

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.

like image 76
brettw Avatar answered Nov 02 '22 08:11

brettw