Java JDBC PostgreSQL Connection getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB)

Here you can find the source of getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB)

Description

get Postgres JDBC Connection

License

Open Source License

Declaration

public static Connection getPostgresJDBCConnection(String host, int port, String nameDB, String userDB,
            String passwordDB) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
    public static Connection getPostgresJDBCConnection(String host, int port, String nameDB, String userDB,
            String passwordDB) throws Exception {
        try {//from   w ww  .ja  va2  s  . co  m
            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;
        }
    }
}

Related

  1. getDataFromTable(String tableName, String[] columns)
  2. getDBConnection()
  3. getListDatabaseFromMaster()
  4. getPostgresConnection()
  5. getPostgresConnection()
  6. getPostgresSQLConnection(String hostname, int portNumber, String databaseName, String dbuser, String dbpasswort)
  7. resetTestDB()