Example usage for java.sql Driver jdbcCompliant

List of usage examples for java.sql Driver jdbcCompliant

Introduction

In this page you can find the example usage for java.sql Driver jdbcCompliant.

Prototype

boolean jdbcCompliant();

Source Link

Document

Reports whether this driver is a genuine JDBC Compliant™ driver.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    Driver myDriver = new org.hsqldb.jdbcDriver();
    DriverManager.registerDriver(myDriver);
    System.out.println(myDriver.acceptsURL("jdbc:mydriver://tutorial/"));
    System.out.println("Major Version: " + myDriver.getMajorVersion());
    System.out.println("Minor Version: " + myDriver.getMinorVersion());
    System.out.println("JDBC COMPLIANT driver? " + myDriver.jdbcCompliant());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    List drivers = Collections.list(DriverManager.getDrivers());
    for (int i = 0; i < drivers.size(); i++) {
        Driver driver = (Driver) drivers.get(i);

        String name = driver.getClass().getName();
        System.out.println(name);

        int majorVersion = driver.getMajorVersion();
        System.out.println(majorVersion);
        int minorVersion = driver.getMinorVersion();
        System.out.println(minorVersion);
        boolean isJdbcCompliant = driver.jdbcCompliant();
        System.out.println(isJdbcCompliant);
    }/*  w ww  .  ja va2  s  .  co m*/
}

From source file:org.apache.jackrabbit.core.util.db.ConnectionFactory.java

/**
 * Creates and returns a pooling JDBC {@link DataSource} for accessing
 * the database identified by the given driver class and JDBC
 * connection URL. The driver class can be <code>null</code> if
 * a specific driver has not been configured.
 *
 * @param driverClass the JDBC driver class, or <code>null</code>
 * @param url the JDBC connection URL/*from   ww  w. jav  a 2s .co m*/
 * @return pooling DataSource for accessing the specified database
 */
private BasicDataSource getDriverDataSource(Class<?> driverClass, String url, String user, String password) {
    BasicDataSource ds = new BasicDataSource();
    created.add(ds);

    if (driverClass != null) {
        Driver instance = null;
        try {
            // Workaround for Apache Derby:
            // The JDBC specification recommends the Class.forName
            // method without the .newInstance() method call,
            // but it is required after a Derby 'shutdown'
            instance = (Driver) driverClass.newInstance();
        } catch (Throwable e) {
            // Ignore exceptions as there's no requirement for
            // a JDBC driver class to have a public default constructor
        }
        if (instance != null) {
            if (instance.jdbcCompliant()) {
                // JCR-3445 At the moment the PostgreSQL isn't compliant because it doesn't implement this method...                   
                ds.setValidationQueryTimeout(3);
            }
        }
        ds.setDriverClassName(driverClass.getName());
    }

    ds.setUrl(url);
    ds.setUsername(user);
    ds.setPassword(password);
    ds.setDefaultAutoCommit(true);
    ds.setTestOnBorrow(false);
    ds.setTestWhileIdle(true);
    ds.setTimeBetweenEvictionRunsMillis(600000); // 10 Minutes
    ds.setMinEvictableIdleTimeMillis(60000); // 1 Minute
    ds.setMaxActive(-1); // unlimited
    ds.setMaxIdle(GenericObjectPool.DEFAULT_MAX_IDLE + 10);
    ds.setValidationQuery(guessValidationQuery(url));
    ds.setAccessToUnderlyingConnectionAllowed(true);
    ds.setPoolPreparedStatements(true);
    ds.setMaxOpenPreparedStatements(-1); // unlimited
    return ds;
}