List of utility methods to do JDBC Connection Create
Connection | getConnection(String url, String userName, String password) get Connection return DriverManager.getConnection(url, userName, password);
|
Connection | getConnection(String url, String username, String password) get Connection return DriverManager.getConnection(url, username, password);
|
Connection | getConnection(String username, String password, String driver, String url) get Connection try { Class.forName(driver); Properties prop = new Properties(); prop.setProperty("user", username); prop.setProperty("password", password); Connection con = DriverManager.getConnection(url, prop); return con; } catch (Exception e) { ... |
Connection | getConnection2() get Connection Connection conn = tl.get(); if (conn == null) { conn = getConnection(); return conn; |
Connection | getConnections(String driver, String url, String user, String pwd) get Connections Connection conn = null; try { Properties props = new Properties(); props.put("remarksReporting", "true"); props.put("user", user); props.put("password", pwd); Class.forName(driver); conn = DriverManager.getConnection(url, props); ... |
Connection | getConnectionWithTransaction(String dbUrl, String dbUser, String dbPassword) get Connection With Transaction try { final Connection conn = DriverManager.getConnection(dbUrl, dbUser, dbPassword); conn.setAutoCommit(false); return conn; } catch (Exception e) { throw new RuntimeException("Cannot get connection", e); |
Connection | getDBConnection() get DB Connection if (DB_DRIVER == null) { DB_DRIVER = System.getProperty("DB_DRIVER"); DB_URL = System.getProperty("DB_URL"); DB_USER = System.getProperty("DB_USER"); DB_PASSWORD = System.getProperty("DB_PASSWORD"); Connection dbConnection = null; try { ... |
Connection | getJdbcOdbcConnection() get Jdbc Odbc Connection String odbcDataSourceName = "test1"; String userName = "test1"; String password = "test1"; return getJdbcOdbcConnection(odbcDataSourceName, userName, password); |
Connection | getNewConnection() This method establishes a new connection with the database using constants above Class.forName("org.mariadb.jdbc.Driver"); return DriverManager.getConnection("jdbc:mariadb://localhost:3306/" + DB, DB_USER, DB_PASS); |
Connection | getPhoenixConnection() get Phoenix Connection Class.forName("com.salesforce.phoenix.jdbc.PhoenixDriver"); String connectionURL = "jdbc:phoenix:" + zkQuorum; Connection r = DriverManager.getConnection(connectionURL); r.setAutoCommit(true); return r; |