Java JDBC Oracle Connection getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Apache License

Declaration

public static Connection getConnection() throws Exception 

Method Source Code


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

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

public class Main {
    private static Connection connection = null;

    public static Connection getConnection() throws Exception {
        if (connection != null) {
            return connection;
        } else {/*from  w  ww  .j a v  a  2 s. co m*/
            String serverName = "IBCDS408";
            String portNumber = "1521";
            String sid = "DEV.BCDSS";
            String dbUrl = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;

            try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                connection = DriverManager.getConnection(dbUrl, "BCDSS_DEV", "developmentonly");
            } catch (Exception e) {
                e.printStackTrace();
            }

            return connection;
        }
    }
}

Related

  1. getConnection()
  2. getConnection()
  3. getConnection()
  4. getConnection()
  5. getConnection()
  6. getConnection(String connectString)
  7. getConnection(String dbType, String dbIp, String dbPort, String dbName, String userName, String password)
  8. getConnection(String ip, String serviceName, String uid, String pwd)
  9. getDatabaseConnection()