Java JDBC Oracle Connection getConnection()

Here you can find the source of getConnection()

Description

This method return a connection with database

License

Open Source License

Exception

Parameter Description
ClassNotFoundException an exception
SQLException an exception

Return

connection

Declaration

public static Connection getConnection() throws ClassNotFoundException, SQLException 

Method Source Code


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

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

import java.sql.SQLException;

public class Main {
    private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";
    private static final String DEFAULT_URL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
    private static final String DEFAULT_USERNAME = "SYSTEM";
    private static final String DEFAULT_PASSWORD = "SHUBHAM";

    /**/*from  w w w .j av  a2s.  c o m*/
     * This method return a connection with database
     *
     * @return connection
     * @throws ClassNotFoundException
     * @throws SQLException
     */
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        Class.forName(DEFAULT_DRIVER);
        Connection connection = DriverManager.getConnection(DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
        return connection;
    }
}

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()
  8. getConnection()
  9. getConnection()