Java 8 Driver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Driver class.

This code example shows how to use the following methods:connect
 
	@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);
	} 
 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:acceptsURL
	@Test 
	public void shouldAcceptsWellFormattedURLOnly() throws ClassNotFoundException, SQLException { 
 
		Driver drv = new OrientJdbcDriver();
 
		assertTrue(drv.acceptsURL("jdbc:orient:local:./working/db/test"));
 
		assertFalse(drv.acceptsURL("local:./working/db/test"));
	} 
 
	@Test 
	public void shouldConnect() throws SQLException { 
 
		Properties info = new Properties();
		info.put("user", "admin");
		info.put("password", "admin");
 
		OrientJdbcConnection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:memory:test", info);
 
		assertNotNull(conn);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getClass, getMajorVersion, getMinorVersion, jdbcCompliant
        final Class<? extends Driver> driverClass = classloader.loadClass( this.adapter.getDriverClassName() ).asSubclass( Driver.class );
        return driverClass.newInstance();
    } 
 
    protected InstalledDriver createInstalledDriver() { 
        int major = this.driver.getMajorVersion();
        int minor = this.driver.getMinorVersion();
        boolean compliant = this.driver.jdbcCompliant();
        return new InstalledDriver(this.adapter.getId(), this.driver.getClass().getName(), null, null, major, minor, compliant );
    } 
 
    @Override 
    public Driver getValue() throws IllegalStateException, IllegalArgumentException {
        return this.driver;
    } 
 
    public Injector<DriverRegistry> getDriverRegistryInjector() { 
        return this.driverRegistryInjector;
    } 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getClass, getMajorVersion, getMinorVersion
		} 
		 
		Class<?> driverClass = Class.forName(args[0]);
		Driver d = (Driver)driverClass.newInstance();
		 
		System.out.println("Driver class: "+d.getClass().getName());
		System.out.println("Driver Major Version: "+d.getMajorVersion());
		System.out.println("Driver Minor Version: "+d.getMinorVersion());		
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:connect
                props.setProperty("user", user);
            } 
            if (password != null) {
                props.setProperty("password", password);
            } 
            Connection connection = driver.connect(url, props);
             
            return connection;
        } catch (Exception e) {
            throw new SQLException(e);
        } 
    } 
 
    @Override 
    public void shutdown() throws SQLException {
  
    } 
 
    public String getDriverClassName() {
        return driverClassName;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:connect
            ConnectionProperties connectionProperties = getConnectionProperties();
            if(connectionProperties != null) {
                connectionProps.putAll(connectionProperties.buildProperties());
            } 
 
            Connection connection = driver.connect(getUrl(), connectionProps);
            if(connection == null) {
                throw new BuildException("Unable to create Liquibase Database instance. Could not connect to the database."); 
            } 
            JdbcConnection jdbcConnection = new JdbcConnection(connection);
 
            Database database = databaseFactory.findCorrectDatabaseImplementation(jdbcConnection);
 
            String schemaName = getDefaultSchemaName();
            if (schemaName != null) {
                database.setDefaultSchemaName(schemaName);
            } 
            String catalogName = getDefaultCatalogName();
            if (catalogName != null) {
                database.setDefaultCatalogName(catalogName);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:acceptsURL
    } 
     
    @Test
    public void testNotAccept() throws Exception {
        Driver driver = new PhoenixDriver();
        assertFalse(driver.acceptsURL("jdbc:phoenix://localhost"));
        assertFalse(driver.acceptsURL("jdbc:phoenix:localhost;test=true;bar=foo"));
        assertFalse(driver.acceptsURL("jdbc:phoenix:localhost;test=true"));
        assertTrue(driver.acceptsURL("jdbc:phoenix:localhost:123"));
        assertTrue(driver.acceptsURL("jdbc:phoenix:localhost:123;untest=true"));
        assertTrue(driver.acceptsURL("jdbc:phoenix:localhost:123;untest=true;foo=bar"));
        DriverManager.deregisterDriver(driver);
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:connect
			} catch (Exception exception) {
				throw new SQLException("Failed to load JDBC driver class " + driverClassName, exception);
			} 
			driver = DriverManager.getDriver(url);
		} 
		Connection connection = driver.connect(url, connectProperties);
		if (defaultDatabase != null) {
			connection.setCatalog(defaultDatabase);
		} 
		return connection;
	} 
 
	public void destroy() throws SQLException { 
		if (driver != null) {
			DriverManager.deregisterDriver(driver);
		} 
	} 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMajorVersion
      return this.driver.connect(u, p);
    } 
 
    @Override 
    public int getMajorVersion() { 
      return this.driver.getMajorVersion();
    } 
 
    @Override 
    public int getMinorVersion() { 
      return this.driver.getMinorVersion();
    } 
 
    @Override 
    public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
      return this.driver.getPropertyInfo(u, p);
    } 
 
    @Override 
    public boolean jdbcCompliant() { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:acceptsURL
		{ 
			throw new SQLException(messages.noLocation(this.id));
		} 
		 
		Driver driver = this.connectionSource;
		if ((driver != null) && !driver.acceptsURL(url))
		{ 
			throw new SQLException(messages.invalidLocation(this.id, url));
		} 
		Driver connectionSource = (driver == null) ? DriverManager.getDriver(url) : driver;
		return new DriverDatabase(this.id, connectionSource, url, new Properties(this.properties), this.credentials, this.weight, this.locality);
	} 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Driver Methods: