Reconnect to database after lost of connection


I have currently the issue, that my webapp loose database connection and could not reconnect automatically.

I have a postgres database in the background that could be on high load sometimes.
Is there a way to configure the jdbc connection to automatically reconnect?



I have a postgres database in the background that could be on high load sometimes

to automatically reconnect

High load of the database server can not be the reason to “loose connection”. CUBA application uses connection pool in front of the database and re-uses several connections many times. Connection pools do reconnection when necessary.

Which connection pool do you use?
Default tomcat’s connection pool (commons dbcp 2) has a number of options which you can use to quickly recover after connection to database server has been lost and then restored, such as “testOnBorrow”, “removeAbandoned” etc.

Hi Alex

thanks for reply.

At the moment, I have configured the connection as followed in context.xml file:

driverClassName="org.postgresql.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" validationQuery="SELECT 1" initialSize="0" maxActive="20" maxWaitMillis="10000" maxTotal="100" maxIdle="5" maxWait="10000" poolPreparedStatements="true" maxOpenPreparedStatements="100" removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true" removeAbandonedTimeout="60" logAbandoned="true" testOnBorrow="true"

Waiting now the result in some days as we have this error maybe once per month.