Db autoreconnect?

Hi!
I’m using JPA (Hibernate in Wildfly 16) in a bunch of Java EE webapps, also in Docker containers.
Sometimes the network path between WF and the DB (Postgres 11) is broken because of many reasons (DB update, etc.) and Hibernate does not like at all this interruption. It does not auto-reconnect to the DB when it resume operation.
Is there some JPA (or even Hibernate-specific) settings I could use to enable auto-reconnect ?

Many thanks!

Ale

Hi,

have you ever found a solution for this? I’m also having this problem, especially if the database server is being rebooted. Then Hibernate seems to lose its connection and I’m getting exceptions…

If you configure connection validation on your datasource, the connections that are broken should be removed from the connection pool automatically. If you know that your database is being rebooted, you can also flush your connection pool directly. Some Jakarta EE containers offer tools like JMX beans to do that.