Java JDBC Oracle Connection createConnection()

Here you can find the source of createConnection()

Description

create Connection

License

Apache License

Declaration

public static Connection createConnection() throws SQLException, ClassNotFoundException 

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 {
    private static Properties properties;

    public static Connection createConnection() throws SQLException, ClassNotFoundException {
        String host = properties.getProperty("hostname");
        String port = properties.getProperty("port");
        String sid = properties.getProperty("sid");
        String username = properties.getProperty("username");
        String password = properties.getProperty("password");

        String url = "jdbc:oracle:thin:@" + host + ":" + port + ":" + sid;

        Class.forName("oracle.jdbc.driver.OracleDriver");
        return DriverManager.getConnection(url, username, password);
    }/*from  w w  w  .j av  a2 s  .  c  om*/
}

Related

  1. createDataBaseConnection(String hostName, String portNumber, String userName, String password)
  2. CreateTableScript(String dbSourceName, String db2SchemaName, String schemaList, String server, int port, String dbName, String userid, String pwd)
  3. getConnection()
  4. getConnection()