Java JDBC Oracle Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Connection getConnection() {
        try {//  w ww.ja  va 2 s.co m
            Class.forName("oracle.jdbc.driver.OracleDriver");
            String url = "jdbc:oracle:thin:@bej301056.cn.oracle.com:1521:house02";
            String username = "transrepo";
            String password = "welcome1";
            Connection conn = DriverManager.getConnection(url, username, password);
            //System.out.println("Create Connection");
            return conn;
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }
}

Related

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