private Connection doGetConnection(Properties properties) throws SQLException { initializeDriver(); Connection connection = DriverManager.getConnection(jdbcUrl, properties); configureConnection(connection); return connection; }
public Connection getConnection() throws SQLException { return doGetConnection(username, password); }
@Override public DataSource tryCreateDataSource(DataSourceProps conf) { ensureGetDriverClass(conf); UnPooledDataSource ds = new UnPooledDataSource(); ds.setDriverClassName(conf.getDriverClassName()); ds.setJdbcUrl(conf.getJdbcUrl()); ds.setUsername(conf.getUsername()); ds.setPassword(conf.getPassword()); ds.setDefaultAutoCommit(conf.getDefaultAutoCommit()); ds.setDriverProperties(conf.getExtProperties()); return ds; }
public Connection getConnection(String username, String password) throws SQLException { return doGetConnection(username, password); }
private Connection doGetConnection(String username, String password) throws SQLException { Properties props = new Properties(driverProperties); if (username != null) { props.setProperty("user", username); } if (password != null) { props.setProperty("password", password); } return doGetConnection(props); }