Java JDBC Oracle Connection getJDBCConn(String hostname, String port, String sid, String username, String pwd)

Here you can find the source of getJDBCConn(String hostname, String port, String sid, String username, String pwd)

Description

create by David.ze 2015/07/11 Class.forName("oracle.jdbc.driver.OracleDriver");

License

Open Source License

Parameter

Parameter Description
hostname a parameter
port a parameter
sid a parameter
username a parameter
pwd a parameter

Declaration

public static Connection getJDBCConn(String hostname, String port, String sid, String username, String pwd)
        throws ClassNotFoundException, SQLException 

Method Source Code


//package com.java2s;

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

import java.sql.SQLException;

public class Main {
    /**//from   w  ww  .j  a  v  a  2  s .  c  o  m
     * create by David.ze 2015/07/11
     * Class.forName("oracle.jdbc.driver.OracleDriver");
     * @param hostname
     * @param port
     * @param sid
     * @param username
     * @param pwd
     * @return
     */
    public static Connection getJDBCConn(String hostname, String port, String sid, String username, String pwd)
            throws ClassNotFoundException, SQLException {

        Connection conn = null;
        Class.forName("oracle.jdbc.driver.OracleDriver");

        String thinLink = "jdbc:oracle:thin:@" + hostname + ":" + port + ":" + sid;

        conn = DriverManager.getConnection(thinLink, username, pwd);
        return conn;

    }
}

Related

  1. getConnection(String connectString)
  2. getConnection(String dbType, String dbIp, String dbPort, String dbName, String userName, String password)
  3. getConnection(String ip, String serviceName, String uid, String pwd)
  4. getDatabaseConnection()
  5. getDBVersion(String dbSourceName, String server, int port, String dbName, String userid, String pwd)
  6. getJDBCConnection()
  7. getOracle10GConnection(String connIP, String port, String dbName, String username, String password)
  8. getOracleConn()
  9. getOracleConnection()