Here you can find the source of getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB)
public static Connection getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB) throws Exception
//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; } } }