DirectConnectorpublic class DirectConnector extends DefaultConnector
Purpose:Use this Connector to build a java.sql.Connection by
directly instantiating the Driver, as opposed to using the DriverManager. |
Fields Summary |
---|
protected Driver | cachedInstancecache up the instantiated Driver to speed up reconnects |
Constructors Summary |
---|
public DirectConnector()PUBLIC:
Construct a Connector with default settings (Sun JDBC-ODBC bridge).
Although this does not really make sense for a "direct" Connector -
the Sun JdbcOdbcDriver works fine with the DriverManager.
super();
| public DirectConnector(String driverClassName, String driverURLHeader, String databaseURL)PUBLIC:
Construct a Connector with the specified settings.
super(driverClassName, driverURLHeader, databaseURL);
|
Methods Summary |
---|
public java.sql.Connection | connect(java.util.Properties properties)INTERNAL:
Connect with the specified properties and return the Connection.
try {
return this.instantiateDriver(this.loadDriver()).connect(this.getConnectionString(), properties);
} catch (SQLException exception) {
throw DatabaseException.sqlException(exception);
}
| protected java.sql.Driver | instantiateDriver(java.lang.Class driverClass)INTERNAL:
Instantiate the Driver if necessary.
if (cachedInstance != null) {
return cachedInstance;
}
try {
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
cachedInstance = (Driver)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(driverClass));
} catch (PrivilegedActionException exception) {
Exception throwableException = exception.getException();
if (throwableException instanceof InstantiationException) {
throw DatabaseException.configurationErrorNewInstanceInstantiationException((InstantiationException)throwableException, driverClass);
} else {
throw DatabaseException.configurationErrorNewInstanceIllegalAccessException((IllegalAccessException)throwableException, driverClass);
}
}
} else {
cachedInstance = (Driver)PrivilegedAccessHelper.newInstanceFromClass(driverClass);
}
return cachedInstance;
} catch (InstantiationException ie) {
throw DatabaseException.configurationErrorNewInstanceInstantiationException(ie, driverClass);
} catch (IllegalAccessException iae) {
throw DatabaseException.configurationErrorNewInstanceIllegalAccessException(iae, driverClass);
}
|
|