Search in sources :

Example 1 with AutoloadedDriver

use of org.apache.derby.iapi.jdbc.AutoloadedDriver in project derby by apache.

the class BasicEmbeddedDataSource40 method findDriver.

/**
 * Return a handle to the internal driver, possibly instantiating it first
 * if it hasn't been booted or if it has been shut down.
 *
 * @return The internal driver handle
 * @throws SQLException
 */
@SuppressWarnings("ResultOfObjectAllocationIgnored")
InternalDriver findDriver() throws SQLException {
    String url = jdbcurl;
    synchronized (this) {
        // shutdown by a 'jdbc:derby:;shutdown=true'
        if (driver == null || !driver.acceptsURL(url)) {
            new org.apache.derby.jdbc.EmbeddedDriver();
            // If we know the driver, we loaded it.   Otherwise only
            // work if DriverManager has already loaded it.
            // DriverManager will throw an exception if driver is not found
            Driver registerDriver = DriverManager.getDriver(url);
            if (registerDriver instanceof AutoloadedDriver) {
                driver = (InternalDriver) AutoloadedDriver.getDriverModule();
            } else {
                driver = (InternalDriver) registerDriver;
            }
        }
    // else driver != null and driver can accept url
    }
    return driver;
}
Also used : InternalDriver(org.apache.derby.iapi.jdbc.InternalDriver) AutoloadedDriver(org.apache.derby.iapi.jdbc.AutoloadedDriver) Driver(java.sql.Driver) AutoloadedDriver(org.apache.derby.iapi.jdbc.AutoloadedDriver)

Aggregations

Driver (java.sql.Driver)1 AutoloadedDriver (org.apache.derby.iapi.jdbc.AutoloadedDriver)1 InternalDriver (org.apache.derby.iapi.jdbc.InternalDriver)1