How to determine/check if primary database is down and switch to secondary database

21 views
Skip to first unread message

Vusumzi Mtimkulu

unread,
May 7, 2024, 7:23:01 AM5/7/24
to Ebean ORM
My app currently connects to default/primary database defined in the yaml file. This works great. The challenge I'm having is determining or checking if this database is is down, so that I can create manual DatabaseConfig object and and connect to the secondary database.  Seems simple enough, think I'm doing something wrong. 


However if the database offline it doesn't seem to throw exceptions I can catch. The try-catch clauses are not cathing the DataSourceInitialiseException, Exception at all

 Log:

10:28:30.460 [main] ERROR i.e.datasource.pool.ConnectionPool - FATAL: DataSourcePool [db] is down or has network error!!! 10:28:30.473 [main] ERROR io.ebean.Ebean - Error trying to create the default Database io.ebean.datasource.DataSourceInitialiseException: Error initialising DataSource: IO Error: The Network Adapter could not establish the connection at..


Rob Bygrave

unread,
May 8, 2024, 3:36:19 AM5/8/24
to Ebean ORM
Maybe catch Throwable ?
Reply all
Reply to author
Forward
0 new messages