Java JDBC Connection Create getConnection()

Here you can find the source of getConnection()

Description

get Connection

License

Open Source License

Declaration

public static Connection getConnection() throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.*;

public class Main {
    public static Connection getConnection() throws SQLException {
        String url;//w  w w .  j a  v  a2  s .c o m
        String address = System.getProperty("de.njsm.stocks.internal.db.databaseAddress");
        String port = System.getProperty("de.njsm.stocks.internal.db.databasePort");
        String name = System.getProperty("de.njsm.stocks.internal.db.databaseName");
        String username = System.getProperty("de.njsm.stocks.internal.db.databaseUsername");
        String password = System.getProperty("de.njsm.stocks.internal.db.databasePassword");

        url = String.format("jdbc:mariadb://%s:%s/%s", address, port, name);

        return DriverManager.getConnection(url, username, password);
    }
}

Related

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