Java JDBC Oracle Connection getOracleDBConnection(String server, String database, String username, String password)

Here you can find the source of getOracleDBConnection(String server, String database, String username, String password)

Description

get Oracle DB Connection

License

Apache License

Declaration

private static Connection getOracleDBConnection(String server, String database, String username,
            String password) throws SQLException 

Method Source Code


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

import java.sql.*;

public class Main {
    private static Connection getOracleDBConnection(String server, String database, String username,
            String password) throws SQLException {
        Connection conn = null;/*ww  w. jav  a 2s.  c  o m*/
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            conn = DriverManager.getConnection("jdbc:oracle:thin:@" + server + ":1521:" + database, username,
                    password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }
}

Related

  1. getJDBCConn(String hostname, String port, String sid, String username, String pwd)
  2. getJDBCConnection()
  3. getOracle10GConnection(String connIP, String port, String dbName, String username, String password)
  4. getOracleConn()
  5. getOracleConnection()
  6. GetSchemaList(String dbSourceName, String server, int port, String dbName, String userid, String pwd)
  7. OpenConnection(String dbSourceName, String server, int port, String dbName, String userid, String pwd)