Java JDBC Connection Create getUrlConnection()

Here you can find the source of getUrlConnection()

Description

get Url Connection

License

Apache License

Declaration

public static Connection getUrlConnection() throws SQLException 

Method Source Code

//package com.java2s;
//  Licensed under the Apache License, Version 2.0 (the "License");

import java.sql.SQLException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.*;

import java.util.logging.*;

public class Main {
    static String url;
    public static Properties props;

    public static Connection getUrlConnection() throws SQLException {
        Connection connection = null;
        checkprops();//  w w w. j  a  v a 2s  . c o  m

        Logger.global.log(Level.FINE, "DriverManager.getConnection(url)");
        connection = DriverManager.getConnection(url);
        Logger.global.log(Level.INFO, "DriverManager.getConnection(url) passed");
        Logger.global.log(Level.FINE, "==============\n\n");

        return connection;
    }

    public static Connection getUrlConnection(String newUrl) throws SQLException {
        Connection connection = null;
        checkprops();

        Logger.global.log(Level.FINE, "DriverManager.getConnection(newUrl)  newUrl = " + newUrl);
        connection = DriverManager.getConnection(newUrl);
        Logger.global.log(Level.INFO, "DriverManager.getConnection(newUrl) passed  mewUrl = " + newUrl);
        Logger.global.log(Level.FINE, "==============\n\n");

        return connection;
    }

    static void checkprops() throws SQLException {
        if (props == null)
            throw new SQLException("Error: t4jdbc.properties is null. Exiting.");
    }
}

Related

  1. getSourceConnection(final Hashtable env)
  2. getStatement(Map config)
  3. getTargetConnection()
  4. getTestDBConnection()
  5. getTRECConnection()
  6. getUserConnection()
  7. internalShutdown(String connectionString, int expectedErrorCode, String expectedSQLState)
  8. runSQLExecute(String sql, Map config)