Java JDBC Oracle Connection getDatabaseConnection()

Here you can find the source of getDatabaseConnection()

Description

get Database Connection

License

Open Source License

Declaration

public static Connection getDatabaseConnection() 

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 DB_URL = "jdbc:oracle:thin:@localhost:1521:xe";
    private static final String USER = "system";
    private static final String PASS = "system";

    public static Connection getDatabaseConnection() {
        Connection conn = null;//from ww w .  j av  a  2  s.c  o  m
        try {
            conn = DriverManager.getConnection(getDbUrl(), getUser(), getPass());
        } catch (SQLException e) {
            System.out.println("DBHelper failed to create database connection");
            e.printStackTrace();
        }

        return conn;
    }

    public static String getDbUrl() {
        return DB_URL;
    }

    public static String getUser() {
        return USER;
    }

    public static String getPass() {
        return PASS;
    }
}

Related

  1. getConnection()
  2. getConnection()
  3. getConnection(String connectString)
  4. getConnection(String dbType, String dbIp, String dbPort, String dbName, String userName, String password)
  5. getConnection(String ip, String serviceName, String uid, String pwd)
  6. getDBVersion(String dbSourceName, String server, int port, String dbName, String userid, String pwd)
  7. getJDBCConn(String hostname, String port, String sid, String username, String pwd)
  8. getJDBCConnection()
  9. getOracle10GConnection(String connIP, String port, String dbName, String username, String password)