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

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

Description

get Connection

License

Apache License

Declaration

public static Connection getConnection(String url, String username, String password) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.*;

public class Main {
    private static Connection conn;

    public static Connection getConnection(String url, String username, String password) {
        if (null == conn) {
            try {
                conn = DriverManager.getConnection(url, username, password);
            } catch (SQLException e) {
                e.printStackTrace();/*from  w  ww .j  a va  2 s . c  o m*/
                throw new RuntimeException(e);
            }
        }
        return conn;
    }
}

Related

  1. getConnection(String drvr, String url, String nm, String pass)
  2. getConnection(String filename)
  3. getConnection(String jdbcDriverName, String connectionURL)
  4. getConnection(String propertiesFilePath)
  5. getConnection(String subprotocol, String subname, String user, String password)
  6. getConnection(String url, String userName, String password)
  7. getConnection(String url, String username, String password)
  8. getConnection(String username, String password, String driver, String url)
  9. getConnection2()