@Test public void testIsConnectable() throws Exception { PostgreDatasource postgreDatasource = new PostgreDatasource(); postgreDatasource.setAddress("jdbc:postgresql: postgreDatasource.setUser("postgres"); postgreDatasource.setDatabase("test01"); postgreDatasource.setPassword("postgres-2017"); postgreDatasource.isConnectable(); }
@Override public void isConnectable() throws Exception { Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(getJdbcUrl(), this.user, this.password); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { logger.error("Postgre datasource try conn close conn error", e); throw e; } } } }
PostgreDatasource extends Datasource { @Override public void isConnectable() throws Exception { Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(getJdbcUrl(), this.user, this.password); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { logger.error("Postgre datasource try conn close conn error", e); throw e; } } } } }
PostgreDatasource extends Datasource { @Override public void isConnectable() throws Exception { Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(getJdbcUrl(), this.user, this.password); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { logger.error("Postgre datasource try conn close conn error", e); throw e; } } } }  }
PostgreDatasource extends Datasource { @Override public void isConnectable() throws Exception { Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(getJdbcUrl(), this.user, this.password); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { logger.error("Postgre datasource try conn close conn error", e); throw e; } } } }  String getAddress(); void setAddress(String address); String getDatabase(); void setDatabase(String database); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); String getJdbcUrl(); @Override void isConnectable(); }
PostgreDatasource extends Datasource { @Override public void isConnectable() throws Exception { Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(getJdbcUrl(), this.user, this.password); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { logger.error("Postgre datasource try conn close conn error", e); throw e; } } } }  String getAddress(); void setAddress(String address); String getDatabase(); void setDatabase(String database); String getUser(); void setUser(String user); String getPassword(); void setPassword(String password); String getJdbcUrl(); @Override void isConnectable();  }