1

The Spring application restarts itself due to Bean creation failure what is caused by the connection exception. The Exception is dropped at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:243) at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38) This happens if we stop the DB before the application startup. That case works fine when DB gets down and then trying to reconnect after the application startup.

Is there any way, any settings to set the DBCP to try to reconnect automatically?

user2695543
  • 81
  • 4
  • 22
  • 1
    See the [configuration options](https://commons.apache.org/proper/commons-dbcp/configuration.html) - starting from the validationQuery parameter, and [typical validationQuery values](https://stackoverflow.com/questions/10684244/dbcp-validationquery-for-different-databases). However, I don't know if some combination of those parameters will allow the app to start if the DB is already down. Experiment and let us know! – Andrew S Feb 14 '18 at 14:11
  • I tried several combinations, but it didn't help. – user2695543 Feb 14 '18 at 18:27
  • A more drastic solution would be to wrap the connection factory and catch/ignore the exception. That should allow the app to start. And if a valid connection cannot be established after a reasonable number of attempts set a flag to redirect all requests to an error page. But that seems like a lot of work for a situation that should hopefully rarely occur. Maybe this is a human communication issue instead of a technology issue? – Andrew S Feb 14 '18 at 18:42

0 Answers0