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 SQLException 

Method Source Code

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

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

public class Main {
    public static Connection getPostgresConnection() throws SQLException {
        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);

    }//from www .j av  a  2  s. c  o m

    public static Connection getConnection() throws SQLException {
        return getDerbyUnitConnection();
    }

    public static Connection getDerbyUnitConnection() throws SQLException {
        String url = "jdbc:derby:memory:flexims;create=true";
        Properties props = new Properties();
        props.setProperty("user", "flexims");
        props.setProperty("password", "123456");
        return DriverManager.getConnection(url, props);

    }
}

Related

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