Java JDBC Connection Create getConnection(String driver, String url, String username, String password)

Here you can find the source of getConnection(String driver, String url, String username, String password)

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection(String driver, String url, String username, String password)
        throws ClassNotFoundException, SQLException 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.DriverManager;

import java.sql.SQLException;

public class Main {

    public static Connection getConnection(String driver, String url, String username, String password)
            throws ClassNotFoundException, SQLException {
        Connection conn = null;//from w ww .ja  va 2  s . c  om
        Class.forName(driver);
        conn = DriverManager.getConnection(url, username, password);
        return conn;
    }
}

Related

  1. getConnection(String dbName)
  2. getConnection(String dbUrl, String dbUser, String dbPassword)
  3. getConnection(String driver, String connectionString, String userName, String password)
  4. getConnection(String driver, String connectString)
  5. getConnection(String driver, String url, String user, String pass)
  6. getConnection(String driverClass, String url, String user, String password)
  7. getConnection(String driverName, String urlprefix, String host, String port, String database, String user, String password)
  8. getConnection(String drvr, String url, String nm, String pass)
  9. getConnection(String filename)