@Override protected boolean doInitialize( ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { postgresqlPort = ConfigUtils.stringToInteger(postgresqlPortString, 5432); try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { getMonitor().error("Couldn't find PostgreSQL JDBC Driver", e); throw new ResourceInitializationException(e); } try { if (!Strings.isNullOrEmpty(postgresqlUser) && !Strings.isNullOrEmpty(postgresqlPass)) { connection = DriverManager.getConnection(getJdbcString(), postgresqlUser, postgresqlPass); } else { connection = DriverManager.getConnection(getJdbcString()); } if (!connection.isValid(1000)) { throw new BaleenException("Couldn't establish PostgreSQL connection"); } } catch (SQLException | BaleenException e) { getMonitor().error("Couldn't establish PostgreSQL connection", e); throw new ResourceInitializationException(e); } return true; }
@Override protected boolean doInitialize( ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { postgresqlPort = ConfigUtils.stringToInteger(postgresqlPortString, 5432); try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { getMonitor().error("Couldn't find PostgreSQL JDBC Driver", e); throw new ResourceInitializationException(e); } try { if (!Strings.isNullOrEmpty(postgresqlUser) && !Strings.isNullOrEmpty(postgresqlPass)) { connection = DriverManager.getConnection(getJdbcString(), postgresqlUser, postgresqlPass); } else { connection = DriverManager.getConnection(getJdbcString()); } if (!connection.isValid(1000)) { throw new BaleenException("Couldn't establish PostgreSQL connection"); } } catch (SQLException | BaleenException e) { getMonitor().error("Couldn't establish PostgreSQL connection", e); throw new ResourceInitializationException(e); } return true; }