Java JDBC PostgreSQL Connection getPostgresConnection()

Here you can find the source of getPostgresConnection()

Description

get Postgres Connection

License

Apache License

Declaration

public static Connection getPostgresConnection() throws ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Connection getPostgresConnection() throws ClassNotFoundException {
        Class.forName("org.postgresql.Driver");
        Connection connection = null;
        try {//  ww w .  j ava2 s  .c  o m

            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();
        }
        return connection;
    }
}

Related

  1. getConnection()
  2. getDataFromTable(String tableName, String[] columns)
  3. getDBConnection()
  4. getListDatabaseFromMaster()
  5. getPostgresConnection()
  6. getPostgresJDBCConnection(String host, int port, String nameDB, String userDB, String passwordDB)
  7. getPostgresSQLConnection(String hostname, int portNumber, String databaseName, String dbuser, String dbpasswort)
  8. resetTestDB()