Java Utililty Methods JDBC Connection Create

List of utility methods to do JDBC Connection Create

Description

The list of methods to do JDBC Connection Create are organized into topic(s).

Method

ConnectiongetConnection()
get Connection
Connection connection = null;
try {
    loadProperties();
    String location = properties.getProperty("db.location"); 
    DB_DRIVER = properties.getProperty("db.driver");
    DB_USER = properties.getProperty("db.username");
    DB_PASSWORD = properties.getProperty("db.password");
    URL = properties.getProperty(location + ".url");
...
ConnectiongetConnection()
Clear the database.
if (connection == null) {
    Properties p = new Properties();
    FileInputStream in = new FileInputStream("test_files/stress/database.properties");
    p.load(in);
    in.close();
    Class.forName(p.getProperty("DatabaseDriver"));
    return DriverManager.getConnection(p.getProperty("DatabaseUrl"), p.getProperty("username"),
            p.getProperty("password"));
...
ConnectiongetConnection()
get Connection
if (connection == null) {
    connection = DriverManager.getConnection(url, username, password);
return connection;
ConnectiongetConnection()
get Connection
Connection con = null;
try {
    con = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
    e.printStackTrace();
return con;
ConnectiongetConnection()
get Connection
Connection con = null;
try {
    Class.forName(db_driver);
} catch (ClassNotFoundException e) {
    System.out.println("3-ClassNotFoundException");
    e.printStackTrace();
    return null;
try {
    con = DriverManager.getConnection(db_url, db_userName, db_passWord);
} catch (SQLException e) {
    System.out.println("4-SQLException");
    e.printStackTrace();
    return null;
return con;
ConnectiongetConnection()
get Connection
Connection con = conList.get();
if (con == null) {
    try {
        con = DriverManager.getConnection(url, username, password);
        conList.set(con);
    } catch (Exception e) {
        throw new RuntimeException(e);
return con;
ConnectiongetConnection()
Creates a sql connection.
Properties prop = new Properties();
FileInputStream fis = null;
try {
    fis = new FileInputStream(DATABASE_PROPERTY_FILE_PATH);
    prop.load(fis);
} finally {
    if (fis != null) {
        fis.close();
...
ConnectiongetConnection()
get Connection
return DriverManager.getConnection(props.getProperty("url"), props.getProperty("username"),
        props.getProperty("password"));
ConnectiongetConnection(@Nonnull String connectUrl)
get Connection
return DriverManager.getConnection(connectUrl);
ConnectiongetConnection(final String driver, final String url)
Create a new JDBC Connection.
Class.forName(driver).newInstance();
return DriverManager.getConnection(url);