void initializeDataSource() throws Exception { Resource monitoringDir = dataDirectory.get("monitoring"); Resource dbprops = monitoringDir.get("db.properties"); if (Resources.exists(dbprops)) { LOGGER.info("Configuring monitoring database from: " + dbprops.path()); // attempt to configure try { configureDataSource(dbprops, monitoringDir); } catch (SQLException e) { // configure failed, try db1.properties dbprops = monitoringDir.get("db1.properties"); if (Resources.exists(dbprops)) { try { configureDataSource(dbprops, monitoringDir); // secondary file worked, return return; } catch (SQLException e1) { // secondary file failed as well, try for third dbprops = monitoringDir.get("db2.properties"); if (Resources.exists(dbprops)) { try { configureDataSource(dbprops, monitoringDir); // third file worked, return return; } catch (SQLException e2) { } } } } throw e; } } else { // no db.properties file, use internal default configureDataSource(null, monitoringDir); } }