Java JDBC Oracle Connection getConnection(String ip, String serviceName, String uid, String pwd)

Here you can find the source of getConnection(String ip, String serviceName, String uid, String pwd)

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection(String ip, String serviceName, String uid, String pwd) throws Exception 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.DriverManager;

public class Main {
    public static Connection getConnection(String ip, String serviceName, String uid, String pwd) throws Exception {
        String driver = "oracle.jdbc.driver.OracleDriver";
        String url = "jdbc:oracle:thin:@" + ip + ":1521:" + serviceName;

        //        String url = "jdbc:oracle:thin:@localhost:1521:ORCL11";
        //        String uid = "dep";
        //        String pwd = "dep";

        //        String url = "jdbc:oracle:thin:@172.29.24.13:1521:dep1";
        //        String uid = "deptestnew";
        //        String pwd = "deptestnew";

        Class.forName(driver);//from   w w w  .  j  ava2  s . c  om
        Connection conn = DriverManager.getConnection(url, uid, pwd);

        return conn;
    }
}

Related

  1. getConnection()
  2. getConnection()
  3. getConnection()
  4. getConnection(String connectString)
  5. getConnection(String dbType, String dbIp, String dbPort, String dbName, String userName, String password)
  6. getDatabaseConnection()
  7. getDBVersion(String dbSourceName, String server, int port, String dbName, String userid, String pwd)
  8. getJDBCConn(String hostname, String port, String sid, String username, String pwd)
  9. getJDBCConnection()