List of utility methods to do JDBC PostgreSQL Connection
void | ClearDatabase() Clear Database String ConnectionString; Connection PostgreSQLConnection; Statement stmt; ConnectionString = "jdbc:postgresql://127.0.0.1:5432/abia/"; try { Class.forName("org.postgresql.Driver"); } catch (Exception e) { System.out.println(e); ... |
Connection | createConnection() create Connection return DriverManager.getConnection(DB_CONNECTION_URL, DB_USERNAME, DB_PASSWORD);
|
Connection | getConnection() get Connection String url = "jdbc:postgresql://localhost/marketplace"; Properties props = new Properties(); props.setProperty("user", "marketplace"); props.setProperty("password", "test"); return DriverManager.getConnection(url, props); |
Connection | getConnection() get Connection Connection con = null; try { Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection(DB_URL, USERNAME, PASSWORD); } catch (ClassNotFoundException | SQLException ex) { System.out.println(ex.getMessage()); return con; ... |
LinkedList | getDataFromTable(String tableName, String[] columns) get Data From Table Connection conn = getConnection(); LinkedList<String> list = new LinkedList<String>(); try { Statement st = conn.createStatement(); String sb = "select * from " + tableName; ResultSet rs = st.executeQuery(sb); while (rs.next()) { StringBuilder sql = new StringBuilder(); ... |
Connection | getDBConnection() get DB Connection if (connection == null) connection = connectToDatabase(); return connection; |
List | getListDatabaseFromMaster() get List Database From Master List<String> lista = new ArrayList<>(); Connection connection; try { Class.forName(driver); connection = (Connection) DriverManager.getConnection(url, user, senha); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT name FROM public.system_database;"); while (resultSet.next()) { ... |
Connection | getPostgresConnection() get Postgres Connection String url = "jdbc:postgresql://192.168.231.10:5432/flexims"; Properties props = new Properties(); props.setProperty("user", "flexims"); props.setProperty("password", "123456"); return DriverManager.getConnection(url, props); |
Connection | getPostgresConnection() get Postgres Connection Class.forName("org.postgresql.Driver"); Connection connection = null; try { connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/jira", "postgres", "Jira733"); } catch (SQLException e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); ... |
Connection | getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB) get Postgres JDBC Connection try { Class.forName("org.postgresql.Driver"); Connection con = null; con = DriverManager.getConnection("jdbc:postgresql://" + host + ":" + port + "/" + nameDB, userDB, passwordDB); return con; } catch (Exception e) { throw e; ... |