Java JDBC Connection Create getConnect(String driver, String url, String user, String password)

Here you can find the source of getConnect(String driver, String url, String user, String password)

Description

get Connect

License

Mozilla Public License

Parameter

Parameter Description
driver a parameter
url a parameter
user a parameter
password a parameter

Exception

Parameter Description
SQLException an exception
ClassNotFoundException an exception

Return

Connection

Declaration

public static Connection getConnect(String driver, String url, String user, String password)
        throws SQLException, ClassNotFoundException 

Method Source Code

//package com.java2s;
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import java.sql.*;

public class Main {
    /**//from w  ww.j  ava 2s  . com
     *
     * @param driver
     * @param url
     * @param user
     * @param password
     * @return Connection
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public static Connection getConnect(String driver, String url, String user, String password)
            throws SQLException, ClassNotFoundException {
        Class.forName(driver);
        return DriverManager.getConnection(url, user, password);
    }
}

Related

  1. createConnection()
  2. createConnection(Properties props, String prefix)
  3. createDatabase(String dbConnectionString, String dbName, String user, String pass, String driver)
  4. createDbConnection(String dbUrl, String dbUser, String dbPass, String dbDriverClass)
  5. getAccessConn(String path)
  6. getConnection()
  7. getConnection()
  8. getConnection()
  9. getConnection()