Java JDBC Connection Create getConnection(String driver, String connectionString, String userName, String password)

Here you can find the source of getConnection(String driver, String connectionString, String userName, String password)

Description

get Connection

License

Open Source License

Declaration

static Connection getConnection(String driver, String connectionString, String userName, String password) 

Method Source Code

//package com.java2s;
/**//from  w  w  w .  j  a v a  2 s . c  om
 * 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;

public class Main {
    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. getConnection(Properties pro)
  2. getConnection(Properties prop)
  3. getConnection(Properties properties)
  4. getConnection(String dbName)
  5. getConnection(String dbUrl, String dbUser, String dbPassword)
  6. getConnection(String driver, String connectString)
  7. getConnection(String driver, String url, String user, String pass)
  8. getConnection(String driver, String url, String username, String password)
  9. getConnection(String driverClass, String url, String user, String password)