Java JDBC Connection Create getTargetConnection()

Here you can find the source of getTargetConnection()

Description

get Target Connection

License

Open Source License

Declaration

static Connection getTargetConnection() 

Method Source Code

//package com.java2s;
/**/*from w w  w.  j  a v a 2s  .com*/
 * Sonar Data Migrator, A tool to migrate sonar project data between to separate sonar instances.
 *
 * Copyright (C) 2013 Worldline or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>
 */

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

import java.util.ResourceBundle;

public class Main {
    static ResourceBundle dbResourceBundle = null;

    static Connection getTargetConnection() {
        return getConnection(dbResourceBundle.getString("targetDriver"),
                dbResourceBundle.getString("targetConnectionString"), dbResourceBundle.getString("targetUserName"),
                dbResourceBundle.getString("targetPassword"));
    }

    static Connection getConnection(String driver, String connectionString, String userName, String password) {
        Connection con = null;
        try {
            Class.forName(driver);
            con = DriverManager.getConnection(connectionString, userName, password);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return con;
    }
}

Related

  1. getJdbcOdbcConnection()
  2. getNewConnection()
  3. getPhoenixConnection()
  4. getSourceConnection(final Hashtable env)
  5. getStatement(Map config)
  6. getTestDBConnection()
  7. getTRECConnection()
  8. getUrlConnection()
  9. getUserConnection()