public class InternalDriver extends java.lang.Object implements ModuleControl, java.sql.Driver
Modifier and Type | Class and Description |
---|---|
private static class |
InternalDriver.DaemonThreadFactory
Thread factory to produce daemon threads which don't block VM shutdown.
|
static class |
InternalDriver.LoginCallable
This code is called in a thread which puts time limits on it.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.concurrent.ExecutorService |
_executorPool
An executor service used for executing connection attempts when a
login timeout has been specified.
|
protected boolean |
active |
private static InternalDriver |
activeDriver |
private AuthenticationService |
authenticationService |
private static java.lang.String[] |
BOOLEAN_CHOICES |
private ContextService |
contextServiceFactory |
private static boolean |
deregister
Tells whether or not
AutoloadedDriver should deregister itself
on shutdown. |
private java.lang.Object |
mbean |
private static java.lang.Object |
syncMe |
Constructor and Description |
---|
InternalDriver() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsURL(java.lang.String url) |
static InternalDriver |
activeDriver() |
void |
boot(boolean create,
java.util.Properties properties)
Boot this module with the given properties.
|
private static void |
checkBoolean(java.util.Properties set,
java.lang.String attribute) |
private static void |
checkEnumeration(java.util.Properties set,
java.lang.String attribute,
java.lang.String[] choices) |
private void |
checkShutdownPrivileges(java.lang.String user)
Checks for shutdown System Privileges.
|
void |
checkSystemPrivileges(java.lang.String user,
java.security.Permission perm)
Checks for System Privileges.
|
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info) |
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info,
int loginTimeoutSeconds) |
static boolean |
embeddedDriverAcceptsURL(java.lang.String url) |
private static java.lang.Object |
findService(java.lang.String factoryInterface,
java.lang.String serviceName)
Privileged service lookup.
|
protected FormatableProperties |
getAttributes(java.lang.String url,
java.util.Properties info)
Convert all the attributes in the url into properties and
combine them with the set provided.
|
AuthenticationService |
getAuthenticationService() |
private ConnectionContext |
getConnectionContext() |
private static ContextService |
getContextService()
Privileged lookup of the ContextService.
|
ContextService |
getContextServiceFactory() |
private ContextManager |
getCurrentContextManager() |
static java.lang.String |
getDatabaseName(java.lang.String url,
java.util.Properties info)
Get the database name from the url.
|
(package private) static boolean |
getDeregister()
Check whether
AutoloadedDriver should deregister itself on
shutdown. |
int |
getMajorVersion() |
int |
getMinorVersion() |
private static ModuleFactory |
getMonitor()
Privileged Monitor lookup.
|
(package private) EmbedConnection |
getNewEmbedConnection(java.lang.String url,
java.util.Properties info) |
java.sql.Connection |
getNewNestedConnection(EmbedConnection conn)
Get a new nested connection.
|
protected javax.sql.PooledConnection |
getNewPooledConnection(BasicEmbeddedDataSource40 eds,
java.lang.String user,
java.lang.String password,
boolean requestPassword)
Create and return an EmbedPooledConnection from the received instance of
EmbeddedDataSource.
|
protected javax.sql.XAConnection |
getNewXAConnection(BasicEmbeddedDataSource40 eds,
ResourceAdapter ra,
java.lang.String user,
java.lang.String password,
boolean requestPassword)
Create and return an EmbedXAConnection from the received instance of
BasicEmbeddedDataSource40.
|
java.util.logging.Logger |
getParentLogger() |
java.sql.DriverPropertyInfo[] |
getPropertyInfo(java.lang.String url,
java.util.Properties info)
The getPropertyInfo method is intended to allow a generic GUI tool to
discover what properties it should prompt a human for in order to get
enough information to connect to a database.
|
private static java.lang.Object |
getSystemModule(java.lang.String factoryInterface)
Privileged module lookup.
|
boolean |
isActive()
Return true if this driver is active.
|
boolean |
jdbcCompliant() |
(package private) BrokeredConnection |
newBrokeredConnection(BrokeredConnectionControl control)
Return a new BrokeredConnection for this implementation.
|
java.sql.CallableStatement |
newEmbedCallableStatement(EmbedConnection conn,
java.lang.String stmt,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
java.sql.DatabaseMetaData |
newEmbedDatabaseMetaData(EmbedConnection conn,
java.lang.String dbname)
Return a new java.sql.DatabaseMetaData instance for this implementation.
|
java.sql.PreparedStatement |
newEmbedPreparedStatement(EmbedConnection conn,
java.lang.String stmt,
boolean forMetaData,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability,
int autoGeneratedKeys,
int[] columnIndexes,
java.lang.String[] columnNames) |
EmbedResultSet |
newEmbedResultSet(EmbedConnection conn,
ResultSet results,
boolean forMetaData,
EmbedStatement statement,
boolean isAtomic)
Return a new java.sql.ResultSet instance for this implementation.
|
EmbedResultSetMetaData |
newEmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo)
Returns a new java.sql.ResultSetMetaData for this implementation
|
java.sql.Statement |
newEmbedStatement(EmbedConnection conn,
boolean forMetaData,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
private java.sql.SQLException |
processException(java.lang.Throwable t)
Process exceptions raised while running a timed login.
|
(package private) static void |
setDeregister(boolean deregister)
Indicate to
AutoloadedDriver whether it should deregister
itself on shutdown. |
void |
stop()
Stop the module.
|
private EmbedConnection |
timeLogin(java.lang.String url,
java.util.Properties info,
int loginTimeoutSeconds)
Enforce the login timeout.
|
private static final java.lang.Object syncMe
private static InternalDriver activeDriver
private java.lang.Object mbean
protected boolean active
private ContextService contextServiceFactory
private AuthenticationService authenticationService
private static boolean deregister
AutoloadedDriver
should deregister itself
on shutdown. This flag is true unless the deregister attribute has been
set to false by the user (DERBY-2905).private static final java.util.concurrent.ExecutorService _executorPool
An executor service used for executing connection attempts when a login timeout has been specified.
DERBY-6107: Core pool size and keep alive timeout should be zero so that no threads are cached. By creating a fresh thread each time a task is submitted, we make sure that the task will run in a thread with the same context class loader as the thread that submitted the task. This is important for example when connecting to a database using the classpath subsubprotocol, and the database lives in the context class loader. If threads are cached, a task may execute in a thread that has a different context class loader.
private static final java.lang.String[] BOOLEAN_CHOICES
public static final InternalDriver activeDriver()
public void boot(boolean create, java.util.Properties properties) throws StandardException
ModuleControl
An implementation's boot method can throw StandardException. If it is thrown the module is not registered by the monitor and therefore cannot be found through a findModule(). In this case the module's stop() method is not called, thus throwing this exception must free up any resources.
When create is true the contents of the properties object
will be written to the service.properties of the persistent
service. Thus any code that requires an entry in service.properties
must explicitly place the value in this properties set
using the put method.
Typically the properties object contains one or more default
properties sets, which are not written out to service.properties.
These default sets are how callers modify the create process. In a
JDBC connection database create the first set of defaults is a properties
object that contains the attributes that were set on the jdbc:derby: URL.
This attributes properties set has the second default properties set as
its default. This set (which could be null) contains the properties
that the user set on their DriverManager.getConnection() call, and are thus
not owned by Derby code, and thus must not be modified by Derby
code.
When create is false the properties object contains all the properties set in the service.properties file plus a limited number of attributes from the JDBC URL attributes or connection properties set. This avoids properties set by the user compromising the boot process. An example of a property passed in from the JDBC world is the bootPassword for encrypted databases.
Code should not hold onto the passed in properties reference after boot time as its contents may change underneath it. At least after the complete boot is completed, the links to all the default sets will be removed.
boot
in interface ModuleControl
StandardException
- Module cannot be started.Monitor
,
ModuleFactory
public void stop()
ModuleControl
stop
in interface ModuleControl
Monitor
,
ModuleFactory
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
acceptsURL
in interface java.sql.Driver
java.sql.SQLException
public static boolean embeddedDriverAcceptsURL(java.lang.String url) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection connect(java.lang.String url, java.util.Properties info, int loginTimeoutSeconds) throws java.sql.SQLException
java.sql.SQLException
private EmbedConnection timeLogin(java.lang.String url, java.util.Properties info, int loginTimeoutSeconds) throws java.sql.SQLException
java.sql.SQLException
private java.sql.SQLException processException(java.lang.Throwable t)
public void checkSystemPrivileges(java.lang.String user, java.security.Permission perm)
user
- The user to be checked for having the permissionperm
- The permission to be checkedjava.security.AccessControlException
- if permissions are missingprivate void checkShutdownPrivileges(java.lang.String user) throws java.sql.SQLException
In addition, for the test to succeed
user
- The user to be checked for shutdown privilegesjava.sql.SQLException
- if the privileges check failspublic int getMajorVersion()
getMajorVersion
in interface java.sql.Driver
public int getMinorVersion()
getMinorVersion
in interface java.sql.Driver
public boolean jdbcCompliant()
jdbcCompliant
in interface java.sql.Driver
protected FormatableProperties getAttributes(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
java.sql.SQLException
- thrown if URL form badprivate static void checkBoolean(java.util.Properties set, java.lang.String attribute) throws java.sql.SQLException
java.sql.SQLException
private static void checkEnumeration(java.util.Properties set, java.lang.String attribute, java.lang.String[] choices) throws java.sql.SQLException
java.sql.SQLException
public static java.lang.String getDatabaseName(java.lang.String url, java.util.Properties info)
url
- The url being used for the connectioninfo
- The properties set being used for the connection, must include
the properties derived from the attributes in the urlpublic final ContextService getContextServiceFactory()
public AuthenticationService getAuthenticationService()
EmbedConnection getNewEmbedConnection(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
java.sql.SQLException
private ConnectionContext getConnectionContext()
private ContextManager getCurrentContextManager()
public boolean isActive()
public java.sql.Connection getNewNestedConnection(EmbedConnection conn)
conn
- The EmbedConnection.public java.sql.Statement newEmbedStatement(EmbedConnection conn, boolean forMetaData, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
public java.sql.PreparedStatement newEmbedPreparedStatement(EmbedConnection conn, java.lang.String stmt, boolean forMetaData, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, int[] columnIndexes, java.lang.String[] columnNames) throws java.sql.SQLException
java.sql.SQLException
- if fails to create statementpublic java.sql.CallableStatement newEmbedCallableStatement(EmbedConnection conn, java.lang.String stmt, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
java.sql.SQLException
- if fails to create statementpublic java.sql.DatabaseMetaData newEmbedDatabaseMetaData(EmbedConnection conn, java.lang.String dbname) throws java.sql.SQLException
java.sql.SQLException
- on failure to create.public EmbedResultSet newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, EmbedStatement statement, boolean isAtomic) throws java.sql.SQLException
conn
- Owning connectionresults
- Top level of language result set treeforMetaData
- Is this for meta-datastatement
- The statement that is creating the SQL ResultSetisAtomic
- java.sql.SQLException
public EmbedResultSetMetaData newEmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo)
columnInfo
- a ResultColumnDescriptor that stores information
about the columns in a ResultSetBrokeredConnection newBrokeredConnection(BrokeredConnectionControl control) throws java.sql.SQLException
java.sql.SQLException
protected javax.sql.PooledConnection getNewPooledConnection(BasicEmbeddedDataSource40 eds, java.lang.String user, java.lang.String password, boolean requestPassword) throws java.sql.SQLException
java.sql.SQLException
protected javax.sql.XAConnection getNewXAConnection(BasicEmbeddedDataSource40 eds, ResourceAdapter ra, java.lang.String user, java.lang.String password, boolean requestPassword) throws java.sql.SQLException
java.sql.SQLException
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties it should prompt a human for in order to get enough information to connect to a database. Note that depending on the values the human has supplied so far, additional values may become necessary, so it may be necessary to iterate though several calls to getPropertyInfo.
getPropertyInfo
in interface java.sql.Driver
url
- The URL of the database to connect to.info
- A proposed list of tag/value pairs that will be sent on
connect open.java.sql.SQLException
- if a database-access error occurs.public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
connect
in interface java.sql.Driver
java.sql.SQLException
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
in interface java.sql.Driver
java.sql.SQLFeatureNotSupportedException
static void setDeregister(boolean deregister)
AutoloadedDriver
whether it should deregister
itself on shutdown.deregister
- whether or not AutoloadedDriver
should
deregister itselfstatic boolean getDeregister()
AutoloadedDriver
should deregister itself on
shutdown.private static ContextService getContextService()
private static ModuleFactory getMonitor()
private static java.lang.Object getSystemModule(java.lang.String factoryInterface)
private static java.lang.Object findService(java.lang.String factoryInterface, java.lang.String serviceName)
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.