@Override public Connection connect(String url, Properties info) throws SQLException { return driver.connect(url, info); }
@Override public Connection openConnection() throws SQLException { Connection connection = driver.connect(connectionUrl, connectionProperties); checkState(connection != null, "Driver returned null connection"); return connection; } }
@Override public Connection connect( String url, Properties info ) throws SQLException { return driver.connect( url, info ); }
@Override public Connection connect(String u, Properties p) throws SQLException { return this.driver.connect(u, p); }
/** * * @throws SQLException */ private Connection createConnection( )throws SQLException { Connection con = null; // Create a Connection directly from the Driver that was loaded // with the context class loader. This is to support JDK1.4 con = m_Driver.connect(m_url, m_ConnectionProtocol ); return con; }
@Override public Connection getConnection() throws SQLException { return driver.connect(jdbcUrl, driverProperties); }
@Override public Connection connect(String u, Properties p) throws SQLException { return this.driver.connect(u, p); }
/** * Wraps the call to the underlying driver's connect method. * * @param url the URL of the database * @param info a collection of string/value pairs * @return a Connection object * @throws SQLException thrown if there is an error connecting to the * database * @see java.sql.Driver#connect(java.lang.String, java.util.Properties) */ @Override public Connection connect(String url, Properties info) throws SQLException { return this.driver.connect(url, info); }
@Override protected Connection getConnectionFromDriver(Properties props) throws SQLException { Driver driver = getDriver(); String url = getUrl(); Assert.notNull(driver, "Driver must not be null"); if (logger.isDebugEnabled()) { logger.debug("Creating new JDBC Driver Connection to [" + url + "]"); } return driver.connect(url, props); }
@Override protected Connection makeConnection(String url, Properties connectionProps) { try { return driver.connect( url, connectionProps ); } catch (SQLException e) { throw convertSqlException( "Error calling Driver#connect", e ); } } }
@Override public Connection getConnection(final String username, final String password) throws SQLException { final Properties cloned = (Properties) driverProperties.clone(); if (username != null) { cloned.put("user", username); if (cloned.containsKey("username")) { cloned.put("username", username); } } if (password != null) { cloned.put("password", password); } return driver.connect(jdbcUrl, cloned); }
public static Connection getConnection(String url) throws SQLException { for (Driver driver : registeredDrivers) { if (driver.acceptsURL(url)) { return driver.connect(url); } } throw new SQLException("No suitable driver"); }
static Connection getConnection(Configuration conf) throws Exception { String jdbcDriver = MetastoreConf.getVar(conf, ConfVars.CONNECTION_DRIVER); Driver driver = (Driver) Class.forName(jdbcDriver).newInstance(); Properties prop = new Properties(); String driverUrl = MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY); String user = MetastoreConf.getVar(conf, ConfVars.CONNECTION_USER_NAME); String passwd = MetastoreConf.getPassword(conf, MetastoreConf.ConfVars.PWD); prop.setProperty("user", user); prop.setProperty("password", passwd); Connection conn = driver.connect(driverUrl, prop); conn.setAutoCommit(true); return conn; }
public Connection createPhysicalConnection(String url, Properties info) throws SQLException { Connection conn; if (getProxyFilters().size() == 0) { conn = getDriver().connect(url, info); } else { conn = new FilterChainImpl(this).connection_connect(info); } createCountUpdater.incrementAndGet(this); return conn; }
private boolean check(String name, DruidDataSource dataSource) { boolean result = true; Driver driver = dataSource.getRawDriver(); Properties info = new Properties(dataSource.getConnectProperties()); String username = dataSource.getUsername(); String password = dataSource.getPassword(); String url = dataSource.getUrl(); // We can't use rawUrl here, because the schema maybe set in url. Connection conn = null; if (info.getProperty("user") == null && username != null) { info.setProperty("user", username); } if (info.getProperty("password") == null && password != null) { info.setProperty("password", password); } try { LOG.debug("Validating " + name + " every " + sleepSeconds + " seconds."); conn = driver.connect(url, info); dataSource.validateConnection(conn); } catch (SQLException e) { LOG.warn("Validation FAILED for " + name + " with url [" + url + "] and username [" + info.getProperty("user") + "]. Exception: " + e.getMessage()); result = false; } finally { JdbcUtils.close(conn); } return result; }
public Connection getConnectionFromLocalDriver(String url, Properties properties) { Collection<Driver> drivers = beeLine.getDrivers(); for (Driver d : drivers) { try { if (d.acceptsURL(url) && beeLine.isSupportedLocalDriver(d)) { String clazzName = d.getClass().getName(); beeLine.debug("Driver name is " + clazzName); Driver driver = (Driver) Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader()) .newInstance(); return driver.connect(url, properties); } } catch (Exception e) { beeLine.error("Fail to connect with a local driver due to the exception:" + e); beeLine.error(e); } } return null; }
/** {@inheritDoc} */ @Override public Connection getConnection(String username, String pwd) throws SQLException { Properties props = this.props.storeToProperties(); if (!F.isEmpty(username)) props.put("user", username); if (!F.isEmpty(pwd)) props.put("password", pwd); return IgniteJdbcThinDriver.register().connect(getUrl(), props); }
public Connection makeConnection() throws SQLException { if ( driver == null ) { try { driver = (Driver) Class.forName( DRIVER ).newInstance(); } catch (Exception e) { throw new HibernateException( "Unable to load JDBC Driver [" + DRIVER + "]", e ); } } return driver.connect( URL, createDriverManagerProperties() ); } }
public ConnectionProxy connection_connect(Properties info) throws SQLException { if (this.pos < filterSize) { return nextFilter() .connection_connect(this, info); } Driver driver = dataSource.getRawDriver(); String url = dataSource.getRawJdbcUrl(); Connection nativeConnection = driver.connect(url, info); if (nativeConnection == null) { return null; } return new ConnectionProxyImpl(dataSource, nativeConnection, info, dataSource.createConnectionId()); }
/** * Creates a connection to the underlying containerized database instance. * * @param queryString query string parameters that should be appended to the JDBC connection URL. * The '?' character must be included * @return a Connection * @throws SQLException if there is a repeated failure to create the connection */ public Connection createConnection(String queryString) throws SQLException { final Properties info = new Properties(); info.put("user", this.getUsername()); info.put("password", this.getPassword()); final String url = constructUrlForConnection(queryString); final Driver jdbcDriverInstance = getJdbcDriverInstance(); try { return Unreliables.retryUntilSuccess(getConnectTimeoutSeconds(), TimeUnit.SECONDS, () -> DB_CONNECT_RATE_LIMIT.getWhenReady(() -> jdbcDriverInstance.connect(url, info))); } catch (Exception e) { throw new SQLException("Could not create new connection", e); } }