public class EmbedConnection extends java.lang.Object implements EngineConnection
There is always a single root (parent) connection. The initial JDBC connection is the root connection. A call to getCurrentConnection() or with the URL jdbc:default:connection yields a nested connection that shares the same root connection as the parent. A nested connection is implemented using this class. The nested connection copies the state of the parent connection and shares some of the same objects (e.g. ContextManager) that are shared across all nesting levels. The proxy also maintains its own state that is distinct from its parent connection (e.g. autocommit or warnings).
SYNCHRONIZATION: Just about all JDBC actions are synchronized across all connections stemming from the same root connection. The synchronization is upon the a synchronized object return by the rootConnection.
Supports
TransactionResourceImpl
Modifier and Type | Field and Description |
---|---|
private boolean |
aborting |
private boolean |
active |
private java.sql.Connection |
applicationConnection
The Connection object the application is using when accessing the
database through this connection.
|
(package private) boolean |
autoCommit |
private int |
connectionHoldAbility |
private java.lang.String |
connString
Cached string representation of the connection id
|
(package private) java.sql.DatabaseMetaData |
dbMetadata |
protected static StandardException |
exceptionClose |
private InternalDriver |
factory
Factory for JDBC objects to be created.
|
private java.util.HashSet<LOBFile> |
lobFiles |
private java.util.HashMap<java.lang.Integer,java.lang.Object> |
lobHashMap |
private int |
lobHMKey |
private java.util.WeakHashMap<java.lang.Object,java.lang.Object> |
lobReferences
Map to keep track of all the lobs associated with this
connection.
|
static LowMemory |
memoryState
Low memory state object for connection requests.
|
(package private) boolean |
needCommit |
static java.sql.SQLException |
NO_MEM
Static exception to be thrown when a Connection request can not
be fulfilled due to lack of memory.
|
private static int |
OP_DECRYPT |
private static int |
OP_ENCRYPT |
private static int |
OP_HARD_UPGRADE |
private static int |
OP_REPLICATION |
private static int |
OP_SHUTDOWN |
private int |
resultSetId
An increasing counter to assign to a ResultSet on its creation.
|
(package private) EmbedConnection |
rootConnection |
private java.sql.SQLWarning |
topWarning |
(package private) TransactionResourceImpl |
tr |
private boolean |
usingNoneAuth |
Constructor and Description |
---|
EmbedConnection(EmbedConnection inputConnection)
Create a new connection based off of the
connection passed in.
|
EmbedConnection(InternalDriver driver,
java.lang.String url,
java.util.Properties info) |
Modifier and Type | Method and Description |
---|---|
void |
abort(java.util.concurrent.Executor executor) |
(package private) void |
addLobFile(LOBFile lobFile)
Add a temporary lob file to the lobFiles set.
|
int |
addLOBMapping(java.lang.Object LOBReference)
Add the locator and the corresponding LOB object into the
HashMap
|
(package private) void |
addLOBReference(java.lang.Object lobReference)
Adds an entry of the lob in WeakHashMap.
|
void |
addWarning(java.sql.SQLWarning newWarning)
Add a warning to the current list of warnings, to follow
this note from Connection.getWarnings.
|
protected void |
beginAborting()
Begin aborting the connection
|
private boolean |
bootDatabase(java.util.Properties info,
boolean softAuthenticationBoot)
Boot database.
|
void |
cancelRunningStatement()
Cancels the current running statement.
|
private void |
checkConflictingCryptoAttributes(java.util.Properties p)
Examines the boot properties looking for conflicting cryptographic
options and commands.
|
private void |
checkDatabaseBooted(Database database,
java.lang.String operation,
java.lang.String dbname)
Check that a database has already been booted.
|
private void |
checkDatabaseCreatePrivileges(java.lang.String user,
java.lang.String dbname)
Checks that a user has the system privileges to create a database.
|
void |
checkForTransactionInProgress()
Check if the transaction is active so that we cannot close down the
connection.
|
protected void |
checkIfClosed()
Raises an exception if the connection is closed.
|
private void |
checkIsDBOwner(int operation)
Check if actual authenticationId is equal to the database owner's.
|
private void |
checkUserCredentials(boolean creatingDatabase,
java.lang.String dbname,
java.util.Properties userInfo) |
private void |
checkUserIsNotARole()
If applicable, check that we don't connect with a user name
that equals a role.
|
private void |
clearLOBMapping()
Clear the HashMap of all entries.
|
void |
clearWarnings()
After this call, getWarnings returns null until a new warning is
reported for this Connection.
|
void |
close()
In some cases, it is desirable to immediately release a
Connection's database and JDBC resources instead of waiting for
them to be automatically released; the close method provides this
immediate release.
|
protected void |
close(StandardException e) |
void |
commit()
Commit makes all changes made since the previous
commit/rollback permanent and releases any database locks
currently held by the Connection.
|
protected void |
commitIfAutoCommit()
If in autocommit, then commit.
|
protected void |
commitIfNeeded()
if a commit is needed, perform it.
|
private java.sql.Savepoint |
commonSetSavepointCode(java.lang.String name,
boolean userSuppliedSavepointName)
Creates a savepoint with the given name (if it is a named
savepoint else we will generate a name because Derby only
supports named savepoints internally) in the current
transaction and returns the new Savepoint object that
represents it.
|
private boolean |
compareDatabaseNames(java.lang.String leftDBName,
java.lang.String rightDBName)
Compare two user-specified database names to see if they identify
the same database.
|
java.sql.Array |
createArrayOf(java.lang.String typeName,
java.lang.Object[] elements) |
java.sql.Blob |
createBlob()
Constructs an object that implements the
Blob interface. |
private boolean |
createBoot(java.util.Properties p)
Examine the attributes set provided for illegal boot
combinations and determine if this is a create boot.
|
java.sql.Clob |
createClob()
Constructs an object that implements the
Clob interface. |
private Database |
createDatabase(java.lang.String dbname,
java.util.Properties info)
Create a new database.
|
java.sql.NClob |
createNClob() |
private static java.lang.Object |
createPersistentService(java.lang.String factoryInterface,
java.lang.String serviceName,
java.util.Properties properties)
Privileged startup.
|
java.sql.SQLXML |
createSQLXML() |
java.sql.Statement |
createStatement()
SQL statements without parameters are normally
executed using Statement objects.
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
JDBC 2.0
Same as createStatement() above, but allows the default result set
type and result set concurrency type to be overridden.
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
JDBC 3.0
Same as createStatement() above, but allows the default result set
type, result set concurrency type and result set holdability type to
be overridden.
|
java.sql.Struct |
createStruct(java.lang.String typeName,
java.lang.Object[] attributes) |
private boolean |
emptyCredential(java.lang.String credential)
Forbid empty or null usernames and passwords.
|
private java.util.Properties |
filterProperties(java.util.Properties inputSet)
Filter out properties from the passed in set of JDBC attributes
to remove any derby.* properties.
|
protected void |
finalize() |
private static java.lang.Object |
findService(java.lang.String factoryInterface,
java.lang.String serviceName)
Privileged service lookup.
|
java.sql.Connection |
getApplicationConnection() |
boolean |
getAutoCommit()
Get the current auto-commit state.
|
java.lang.String |
getCatalog()
Return the Connection's current catalog name.
|
java.util.Properties |
getClientInfo()
getClientInfo always returns an empty
Properties object since Derby doesn't support
ClientInfoProperties. |
java.lang.String |
getClientInfo(java.lang.String name)
getClientInfo always returns a
null String since Derby doesn't support
ClientInfoProperties. |
protected java.lang.Object |
getConnectionSynchronization() |
ContextManager |
getContextManager()
Return the context manager for this connection.
|
java.lang.String |
getCurrentSchemaName()
Obtain the name of the current schema.
|
protected Database |
getDatabase() |
java.lang.String |
getDBName()
Return the dbname for this connection.
|
int |
getEngineType()
Gets the EngineType of the connected database.
|
int |
getHoldability()
JDBC 3.0
Retrieves the current holdability of ResultSet objects created using this
Connection object.
|
private int |
getIncLOBKey()
Return the current locator value/
0x800x values are not valid values as they are used to indicate the BLOB
is being sent by value, so we skip those values (DERBY-3243)
|
LanguageConnectionContext |
getLanguageConnection() |
private java.util.HashMap<java.lang.Integer,java.lang.Object> |
getlobHMObj()
Return the Hash Map in the root connection
|
java.lang.Object |
getLOBMapping(int key)
Get the LOB reference corresponding to the locator.
|
InternalDriver |
getLocalDriver() |
java.sql.DatabaseMetaData |
getMetaData()
A Connection's database is able to provide information
describing its tables, its supported SQL grammar, its stored
procedures, the capabilities of this connection, etc.
|
(package private) static ModuleFactory |
getMonitor()
Privileged Monitor lookup.
|
int |
getNetworkTimeout() |
int |
getPrepareIsolation()
Return prepare isolation
|
private java.lang.String |
getReplicationOperation(java.util.Properties p) |
(package private) int |
getResultSetOrderId()
Return a unique order number for a result set.
|
java.lang.String |
getSchema()
Get the name of the current schema.
|
protected TransactionResourceImpl |
getTR() |
int |
getTransactionIsolation()
Get this Connection's current transaction isolation mode.
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
getTypeMap()
Returns the type map for this connection.
|
java.sql.SQLWarning |
getWarnings()
The first warning reported by calls on this Connection is
returned.
|
private void |
handleDBNotFound() |
(package private) java.sql.SQLException |
handleException(java.lang.Throwable thrownException) |
(package private) java.sql.SQLException |
handleException(java.lang.Throwable thrownException,
boolean rollbackOnAutoCommit)
Handle any type of Exception.
|
private void |
handleFailoverMaster(TransactionResourceImpl tr)
Used to authorize and verify the privileges of the user and
initiate failover.
|
private void |
handleFailoverSlave(Database database)
Used to perform failover on a database in slave replication
mode.
|
private void |
handleStartReplicationMaster(TransactionResourceImpl tr,
java.util.Properties p) |
private void |
handleStopReplicationMaster(TransactionResourceImpl tr,
java.util.Properties p) |
private void |
handleStopReplicationSlave(Database database,
java.util.Properties p)
Stop replication slave when called from a client.
|
private void |
internalStopReplicationSlave(Database database,
java.util.Properties p)
Stop replication slave when called from SlaveDatabase.
|
boolean |
isAborting()
Return true if the connection is aborting
|
boolean |
isClosed()
Tests to see if a Connection is closed.
|
private boolean |
isCryptoBoot(java.util.Properties p)
Examines boot properties and determines if a boot with the given
attributes would entail a cryptographic operation on the database.
|
private boolean |
isDropDatabase(java.util.Properties p)
Examines the boot properties and determines if the given attributes
would entail dropping the database.
|
private boolean |
isHardUpgradeBoot(java.util.Properties p)
Examine boot properties and determine if a boot with the given
attributes would entail a hard upgrade.
|
boolean |
isInGlobalTransaction()
Is this a global transaction
|
private boolean |
isInternalShutdownSlaveDatabase(java.util.Properties p)
Examine the boot properties and determine if a boot with the
given attributes should stop slave replication mode.
|
boolean |
isReadOnly()
Tests to see if the connection is in read-only mode.
|
private boolean |
isReplicationFailover(java.util.Properties p)
used to verify if the failover attribute has been set.
|
private static boolean |
isSet(java.util.Properties p,
java.lang.String attribute)
Tells if the attribute/property has been set.
|
private boolean |
isStartReplicationMasterBoot(java.util.Properties p) |
private boolean |
isStartReplicationSlaveBoot(java.util.Properties p) |
private boolean |
isStopReplicationMasterBoot(java.util.Properties p) |
private boolean |
isStopReplicationSlaveBoot(java.util.Properties p)
Examine the boot properties and determine if a boot with the
given attributes should stop slave replication mode.
|
private static boolean |
isTrue(java.util.Properties p,
java.lang.String attribute)
Tells if the attribute/property has the value
true . |
boolean |
isValid(int timeout)
Checks if the connection has not been closed and is still valid.
|
boolean |
isWrapperFor(java.lang.Class<?> interfaces)
Returns false unless
interfaces is implemented |
java.lang.String |
nativeSQL(java.lang.String sql)
A driver may convert the JDBC sql grammar into its system's
native SQL grammar prior to sending it; nativeSQL returns the
native form of the statement that the driver would have sent.
|
protected void |
needCommit()
if auto commit is on, remember that we need to commit
the current statement.
|
(package private) static java.sql.SQLException |
newSQLException(java.lang.String messageId,
java.lang.Object... args) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
A SQL stored procedure call statement is handled by creating a
CallableStatement for it.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
JDBC 2.0
Same as prepareCall() above, but allows the default result set
type and result set concurrency type to be overridden.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
JDBC 3.0
Same as prepareCall() above, but allows the default result set
type, result set concurrency type and result set holdability
to be overridden.
|
(package private) java.sql.PreparedStatement |
prepareMetaDataStatement(java.lang.String sql) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
A SQL statement with or without IN parameters can be
pre-compiled and stored in a PreparedStatement object.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Creates a default PreparedStatement object that has the capability to
retieve auto-generated keys.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Creates a default PreparedStatement object capable of returning
the auto-generated keys designated by the given array.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
JDBC 2.0
Same as prepareStatement() above, but allows the default result set
type and result set concurrency type to be overridden.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
JDBC 3.0
Same as prepareStatement() above, but allows the default result set
type, result set concurrency type and result set holdability
to be overridden.
|
private java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability,
int autoGeneratedKeys,
int[] columnIndexes,
java.lang.String[] columnNames) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Creates a default PreparedStatement object capable of returning
the auto-generated keys designated by the given array.
|
private LanguageConnectionContext |
privilegedGetLCC()
Private, privileged lookup of the lcc..
|
private EmbedConnectionContext |
pushConnectionContext(ContextManager cm) |
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Removes the given Savepoint object from the current transaction.
|
(package private) void |
removeLobFile(LOBFile lobFile)
Remove LOBFile from the lobFiles set.
|
void |
removeLOBMapping(int key)
Remove the key(LOCATOR) from the hash table.
|
private static void |
removePersistentService(java.lang.String name)
Privileged shutdown.
|
private java.util.Properties |
removePhaseTwoProps(java.util.Properties p)
Remove any encryption or upgarde properties from the given properties
|
void |
resetFromPool()
Reset the connection before it is returned from a PooledConnection
to a new application request (wrapped by a BrokeredConnection).
|
protected void |
restoreContextStack() |
void |
rollback()
Rollback drops all changes made since the previous
commit/rollback and releases any database locks currently held
by the Connection.
|
void |
rollback(java.sql.Savepoint savepoint)
Undoes all changes made after the given Savepoint object was set.
|
void |
setApplicationConnection(java.sql.Connection applicationConnection) |
void |
setAutoCommit(boolean autoCommit)
If a connection is in auto-commit mode, then all its SQL
statements will be executed and committed as individual
transactions.
|
void |
setCatalog(java.lang.String catalog)
A sub-space of this Connection's database may be selected by setting a
catalog name.
|
void |
setClientInfo(java.util.Properties properties)
setClientInfo will throw a
SQLClientInfoException unless the properties
parameter is empty, since Derby does not support any
properties. |
void |
setClientInfo(java.lang.String name,
java.lang.String value)
setClientInfo will always throw a
SQLClientInfoException since Derby does not support
any properties. |
void |
setDrdaID(java.lang.String drdaID)
Set the DRDA identifier for this connection.
|
void |
setHoldability(int holdability)
JDBC 3.0
Changes the holdability of ResultSet objects created using this
Connection object to the given holdability.
|
void |
setInactive()
Close the connection when processing errors, or when
closing a nested connection.
|
void |
setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds) |
void |
setPrepareIsolation(int level)
Set the transaction isolation level that will be used for the
next prepare.
|
void |
setReadOnly(boolean readOnly)
You can put a connection in read-only mode as a hint to enable
database optimizations.
|
private int |
setResultSetType(int resultSetType) |
java.sql.Savepoint |
setSavepoint()
Creates an unnamed savepoint in the current transaction and
returns the new Savepoint object that represents it.
|
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a savepoint with the given name in the current transaction and
returns the new Savepoint object that represents it.
|
void |
setSchema(java.lang.String schemaName)
Set the default schema for the Connection.
|
void |
setTransactionIsolation(int level)
You can call this method to try to change the transaction
isolation level using one of the TRANSACTION_* values.
|
void |
setTypeMap(java.util.Map map)
Install a type-map object as the default type-map for
this connection.
|
protected void |
setupContextStack()
Install the context manager for this thread.
|
private static void |
sleep(long millis)
Puts the current thread to sleep.
|
private static boolean |
startPersistentService(java.lang.String serviceName,
java.util.Properties properties)
Privileged startup.
|
static java.lang.String |
stripSubSubProtocolPrefix(java.lang.String dbname)
Strips any sub-sub-protocol prefix from a database name.
|
java.lang.String |
toString()
Get a String representation that uniquely identifies
this connection.
|
boolean |
transactionIsIdle()
returns false if there is an underlying transaction and that transaction
has done work.
|
<T> T |
unwrap(java.lang.Class<T> interfaces)
Returns
this if this class implements the interface |
private void |
verifySavepointArg(java.sql.Savepoint savepoint) |
private void |
verifySavepointCommandIsAllowed() |
private static boolean |
vetTrue(java.util.Properties p,
java.lang.String attribute)
Returns true if the attribute exists and is set to true.
|
void |
xa_commit(boolean onePhase)
Do not use this method directly use XATransactionState.xa_commit
instead because it also maintains/cancels the timout task which is
scheduled to cancel/rollback the global transaction.
|
int |
xa_prepare()
Do not use this method directly use XATransactionState.xa_prepare
instead because it also maintains/cancels the timeout task which is
scheduled to cancel/rollback the global transaction.
|
void |
xa_rollback()
Do not use this method directly use XATransactionState.xa_rollback
instead because it also maintains/cancels the timout task which is
scheduled to cancel/rollback the global transaction.
|
protected static final StandardException exceptionClose
public static final java.sql.SQLException NO_MEM
public static final LowMemory memoryState
java.sql.DatabaseMetaData dbMetadata
TransactionResourceImpl tr
private java.util.HashMap<java.lang.Integer,java.lang.Object> lobHashMap
private int lobHMKey
private java.util.WeakHashMap<java.lang.Object,java.lang.Object> lobReferences
private java.util.HashSet<LOBFile> lobFiles
private boolean active
private boolean aborting
boolean autoCommit
boolean needCommit
private boolean usingNoneAuth
private int connectionHoldAbility
final EmbedConnection rootConnection
private java.sql.SQLWarning topWarning
private InternalDriver factory
private java.sql.Connection applicationConnection
private int resultSetId
private java.lang.String connString
private static final int OP_ENCRYPT
private static final int OP_SHUTDOWN
private static final int OP_HARD_UPGRADE
private static final int OP_REPLICATION
private static final int OP_DECRYPT
public EmbedConnection(InternalDriver driver, java.lang.String url, java.util.Properties info) throws java.sql.SQLException
java.sql.SQLException
public EmbedConnection(EmbedConnection inputConnection)
inputConnection
- the input connectionprivate void checkDatabaseBooted(Database database, java.lang.String operation, java.lang.String dbname) throws java.sql.SQLException
database
- The database that should have been bootedoperation
- The operation that requires that the database has
already been booted, used in the exception message if not booteddbname
- The name of the database that should have been booted,
used in the exception message if not bootedjava.sql.SQLException
- thrown if database is not bootedprivate boolean createBoot(java.util.Properties p) throws java.sql.SQLException
p
- the attribute set.java.sql.SQLException
- Throw if more than one of
create, createFrom, restoreFrom and
rollForwardRecoveryFrom is used simultaneously. private void handleDBNotFound() throws java.sql.SQLException
java.sql.SQLException
private boolean isDropDatabase(java.util.Properties p)
p
- the attribute settrue
if the drop database operation is requested,
false
if not.private boolean isCryptoBoot(java.util.Properties p) throws java.sql.SQLException
p
- the attribute settrue
if a boot will perform a cryptographic operation on
the database.java.sql.SQLException
private boolean isHardUpgradeBoot(java.util.Properties p)
p
- the attribute setprivate boolean isStartReplicationSlaveBoot(java.util.Properties p)
private boolean isStartReplicationMasterBoot(java.util.Properties p)
private boolean isReplicationFailover(java.util.Properties p)
p
- The attribute set.private boolean isStopReplicationMasterBoot(java.util.Properties p)
private boolean isStopReplicationSlaveBoot(java.util.Properties p)
p
- The attribute set.private boolean isInternalShutdownSlaveDatabase(java.util.Properties p)
p
- The attribute set.private static boolean isSet(java.util.Properties p, java.lang.String attribute)
private static boolean isTrue(java.util.Properties p, java.lang.String attribute)
true
.private static boolean vetTrue(java.util.Properties p, java.lang.String attribute) throws java.sql.SQLException
java.sql.SQLException
private java.lang.String getReplicationOperation(java.util.Properties p) throws StandardException
StandardException
private void handleStartReplicationMaster(TransactionResourceImpl tr, java.util.Properties p) throws java.sql.SQLException
java.sql.SQLException
private void handleStopReplicationMaster(TransactionResourceImpl tr, java.util.Properties p) throws java.sql.SQLException
java.sql.SQLException
private void handleStopReplicationSlave(Database database, java.util.Properties p) throws StandardException, java.sql.SQLException
database
- The database the stop slave operation will be
performed onp
- The Attribute set.StandardException
- Thrown on error, if not in replication
slave mode or if the network connection with the master is not downjava.sql.SQLException
- Thrown if the database has not been
booted or if stopSlave is performed successfullyprivate void internalStopReplicationSlave(Database database, java.util.Properties p) throws StandardException, java.sql.SQLException
database
- The database the internal stop slave operation
will be performed onp
- The Attribute set.StandardException
- Thrown on error or if not in replication
slave modejava.sql.SQLException
- Thrown if the database has not been
booted or if this connection was not made internally from
SlaveDatabaseprivate void handleFailoverMaster(TransactionResourceImpl tr) throws java.sql.SQLException, StandardException
tr
- an instance of TransactionResourceImpl Links the connection
to the database.StandardException
- 1) If the failover succeeds, an exception is
thrown to indicate that the master database
was shutdown after a successful failover
2) If a failure occurs during network
communication with slave.java.sql.SQLException
- 1) Thrown upon a authorization failure.private void handleFailoverSlave(Database database) throws java.sql.SQLException
database
- The database the failover operation will be
performed onjava.sql.SQLException
- Thrown on error, if not in replication
slave mode or if the network connection with the master is not downprivate java.util.Properties removePhaseTwoProps(java.util.Properties p)
p
- the attribute setprivate void checkUserCredentials(boolean creatingDatabase, java.lang.String dbname, java.util.Properties userInfo) throws java.sql.SQLException
java.sql.SQLException
private boolean emptyCredential(java.lang.String credential)
Forbid empty or null usernames and passwords.
private boolean compareDatabaseNames(java.lang.String leftDBName, java.lang.String rightDBName) throws java.sql.SQLException
java.sql.SQLException
private void checkUserIsNotARole() throws java.sql.SQLException
java.sql.SQLException
- Will throw if the current authorization
id in lcc
(which is already normalized to
case normal form - CNF) equals an existing role name
(which is also stored in CNF).private void checkIsDBOwner(int operation) throws java.sql.SQLException
operation
- attempted operation which needs database owner powersjava.sql.SQLException
- if actual authenticationId is different
from authenticationId of database owner.public int getEngineType()
public final java.sql.Statement createStatement() throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public final java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXjava.sql.SQLException
- if a database-access error occurs.public final java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXresultSetHoldability
- a holdability type,
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMITjava.sql.SQLException
- if a database-access error occurs.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement is executed. This has no direct affect on users; however, it does affect which method throws certain SQLExceptions. JDBC 2.0 Result sets created using the returned PreparedStatement will have forward-only type, and read-only concurrency, by default.
prepareStatement
in interface java.sql.Connection
sql
- a SQL statement that may contain one or more '?' IN
parameter placeholdersjava.sql.SQLException
- if a database-access error occurs.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXjava.sql.SQLException
- if a database-access error occurs.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXresultSetHoldability
- - one of the following ResultSet constants:
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMITjava.sql.SQLException
- if a database-access error occurs.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- An SQL statement that may contain one or more ? IN parameter placeholderscolumnIndexes
- An array of column indexes indicating the columns
that should be returned from the inserted row or rowsjava.sql.SQLException
- Thrown on error.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- An SQL statement that may contain one or more ? IN parameter placeholderscolumnNames
- An array of column names indicating the columns
that should be returned from the inserted row or rowsjava.sql.SQLException
- Thrown on error.public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
sql
- A SQL statement that may contain one or more ? IN parameter placeholdersautoGeneratedKeys
- A flag indicating whether auto-generated keys
should be returnedjava.sql.SQLException
- Feature not implemented for now.private java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys, int[] columnIndexes, java.lang.String[] columnNames) throws java.sql.SQLException
java.sql.SQLException
public final java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
Note: This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the prepareCall is done; others may wait until the CallableStatement is executed. This has no direct affect on users; however, it does affect which method throws certain SQLExceptions. JDBC 2.0 Result sets created using the returned CallableStatement will have forward-only type, and read-only concurrency, by default.
prepareCall
in interface java.sql.Connection
sql
- a SQL statement that may contain one or more '?'
parameter placeholders. Typically this statement is a JDBC
function call escape string.java.sql.SQLException
- if a database-access error occurs.public final java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXjava.sql.SQLException
- if a database-access error occurs.public final java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
resultSetType
- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency
- a concurrency type, see ResultSet.CONCUR_XXXresultSetHoldability
- - one of the following ResultSet constants:
ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMITjava.sql.SQLException
- if a database-access error occurs.public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
sql
- a SQL statement that may contain one or more '?'
parameter placeholdersjava.sql.SQLException
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
autoCommit
- true enables auto-commit; false disables
auto-commit.java.sql.SQLException
- if a database-access error occurs.public boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
setAutoCommit(boolean)
public void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.setAutoCommit(boolean)
public void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.setAutoCommit(boolean)
public void close() throws java.sql.SQLException
Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public void checkForTransactionInProgress() throws java.sql.SQLException
java.sql.SQLException
- if this transaction is active and the connection
cannot be closedprotected void close(StandardException e) throws java.sql.SQLException
java.sql.SQLException
public final boolean isClosed()
isClosed
in interface java.sql.Connection
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public final int getHoldability() throws java.sql.SQLException
getHoldability
in interface java.sql.Connection
java.sql.SQLException
public final void setHoldability(int holdability) throws java.sql.SQLException
setHoldability
in interface java.sql.Connection
holdability
- A ResultSet holdability constant, one of ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMITjava.sql.SQLException
public final void setReadOnly(boolean readOnly) throws java.sql.SQLException
Note: setReadOnly cannot be called while in the middle of a transaction.
setReadOnly
in interface java.sql.Connection
readOnly
- true enables read-only mode; false disables
read-only mode.java.sql.SQLException
- if a database-access error occurs.public final boolean isReadOnly() throws java.sql.SQLException
isReadOnly
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public void setTransactionIsolation(int level) throws java.sql.SQLException
Note: setTransactionIsolation causes the current transaction to commit if the isolation level is changed. Otherwise, if the requested isolation level is the same as the current isolation level, this method is a no-op.
setTransactionIsolation
in interface java.sql.Connection
level
- one of the TRANSACTION_* isolation values with the
exception of TRANSACTION_NONE; some databases may not support
other valuesjava.sql.SQLException
- if a database-access error occurs.DatabaseMetaData.supportsTransactionIsolationLevel(int)
public final int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
- if a database-access error occurs.public final java.sql.SQLWarning getWarnings() throws java.sql.SQLException
Note: Subsequent warnings will be chained to this SQLWarning.
getWarnings
in interface java.sql.Connection
java.sql.SQLException
public final void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
public final void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
java.sql.SQLException
- Feature not implemented for now.public final void addWarning(java.sql.SQLWarning newWarning)
addWarning
in interface EngineConnection
newWarning
- Warning to be added, will be chained to any
existing warnings.Connection.getWarnings()
public java.lang.String getDBName()
public final LanguageConnectionContext getLanguageConnection()
protected final void checkIfClosed() throws java.sql.SQLException
java.sql.SQLException
- if the connection is closedjava.sql.SQLException handleException(java.lang.Throwable thrownException) throws java.sql.SQLException
java.sql.SQLException
final java.sql.SQLException handleException(java.lang.Throwable thrownException, boolean rollbackOnAutoCommit) throws java.sql.SQLException
thrownException
- the exceptionrollbackOnAutoCommit
- rollback the xact on if autocommit is
on, otherwise rollback stmt but leave xact open (and
continue to hold on to locks). Most of the time, this
will be true, excepting operations on result sets, like
getInt().java.sql.SQLException
public final void setInactive()
This only marks it as closed and frees up its resources; any closing of the underlying connection or commit work is assumed to be done elsewhere. Called from EmbedConnectionContext's cleanup routine, and by proxy.close().
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- standard error policyprotected void needCommit()
protected void commitIfNeeded() throws java.sql.SQLException
java.sql.SQLException
- if commit returns errorprotected void commitIfAutoCommit() throws java.sql.SQLException
java.sql.SQLException
- if commit returns errorprotected final java.lang.Object getConnectionSynchronization()
protected final void setupContextStack() throws java.sql.SQLException
java.sql.SQLException
- if failsprotected final void restoreContextStack() throws java.sql.SQLException
java.sql.SQLException
private Database createDatabase(java.lang.String dbname, java.util.Properties info) throws java.sql.SQLException
dbname
- the database nameinfo
- the propertiesjava.sql.SQLException
- if fails to create databaseprivate void checkDatabaseCreatePrivileges(java.lang.String user, java.lang.String dbname) throws java.sql.SQLException
In addition, for the test to succeed
user
- The user to be checked for database create privilegesdbname
- the name of the database to createjava.sql.SQLException
- if the privileges check failsprivate static void sleep(long millis)
NOTE: This method guarantees that the thread sleeps at
least millis
milliseconds.
millis
- milliseconds to sleeppublic static java.lang.String stripSubSubProtocolPrefix(java.lang.String dbname)
dbname
- a database namejava.lang.NullPointerException
- if dbname is nullprivate boolean bootDatabase(java.util.Properties info, boolean softAuthenticationBoot) throws java.lang.Throwable
info
- boot propertiessoftAuthenticationBoot
- If true, don't fail soft upgrade due
to missing features (phase one of two phased hard upgrade boot).java.lang.Throwable
- if anything else is wrong.java.sql.PreparedStatement prepareMetaDataStatement(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public final InternalDriver getLocalDriver()
public final ContextManager getContextManager()
private java.util.Properties filterProperties(java.util.Properties inputSet)
protected Database getDatabase()
protected final TransactionResourceImpl getTR()
private EmbedConnectionContext pushConnectionContext(ContextManager cm)
public final void setApplicationConnection(java.sql.Connection applicationConnection)
public final java.sql.Connection getApplicationConnection()
public void setDrdaID(java.lang.String drdaID)
EngineConnection
setDrdaID
in interface EngineConnection
public boolean isInGlobalTransaction()
EngineConnection
isInGlobalTransaction
in interface EngineConnection
EngineConnection.isInGlobalTransaction()
public void resetFromPool() throws java.sql.SQLException
resetFromPool
in interface EngineConnection
java.sql.SQLException
public final int xa_prepare() throws java.sql.SQLException
XATransactionController.XA_OK
or
XATransactionController.XA_RDONLY
java.sql.SQLException
public final void xa_commit(boolean onePhase) throws java.sql.SQLException
java.sql.SQLException
public final void xa_rollback() throws java.sql.SQLException
java.sql.SQLException
public final boolean transactionIsIdle()
private int setResultSetType(int resultSetType)
public void setPrepareIsolation(int level) throws java.sql.SQLException
setPrepareIsolation
in interface EngineConnection
level
- Isolation level to change to. level is the DB2 level
specified in the package names which happen to correspond
to our internal levels. If
level == TransactionControl.UNSPECIFIED_ISOLATION,
the statement won't be prepared with an isolation level.java.sql.SQLException
public int getPrepareIsolation()
getPrepareIsolation
in interface EngineConnection
final int getResultSetOrderId()
static java.sql.SQLException newSQLException(java.lang.String messageId, java.lang.Object... args)
public java.lang.String toString()
toString
in class java.lang.Object
public java.sql.Clob createClob() throws java.sql.SQLException
Clob
interface. The object
returned initially contains no data. The setAsciiStream
,
setCharacterStream
and setString
methods of
the Clob
interface may be used to add data to the Clob
.createClob
in interface java.sql.Connection
Clob
interfacejava.sql.SQLException
- if an object that implements the
Clob
interface can not be constructed, this method is
called on a closed connection or a database access error occurs.public java.sql.Blob createBlob() throws java.sql.SQLException
Blob
interface. The object
returned initially contains no data. The setBinaryStream
and
setBytes
methods of the Blob
interface may be used to add data to
the Blob
.createBlob
in interface java.sql.Connection
Blob
interfacejava.sql.SQLException
- if an object that implements the
Blob
interface can not be constructed, this method is
called on a closed connection or a database access error occurs.public int addLOBMapping(java.lang.Object LOBReference)
LOBReference
- The object which contains the LOB object that
that is added to the HashMap.public void removeLOBMapping(int key)
key
- an integer that represents the locator that needs to be
removed from the table.public java.lang.Object getLOBMapping(int key)
getLOBMapping
in interface EngineConnection
key
- the integer that represents the LOB locator value.private void clearLOBMapping() throws java.sql.SQLException
java.sql.SQLException
private int getIncLOBKey()
void addLOBReference(java.lang.Object lobReference)
lobReference
- LOB Objectprivate java.util.HashMap<java.lang.Integer,java.lang.Object> getlobHMObj()
public void cancelRunningStatement()
public java.lang.String getCurrentSchemaName()
getCurrentSchemaName
in interface EngineConnection
void addLobFile(LOBFile lobFile)
lobFile
- LOBFile to addvoid removeLobFile(LOBFile lobFile)
lobFile
- LOBFile to remove.public boolean isAborting()
protected void beginAborting()
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurs or
this Connection object is currently in auto-commit modepublic java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
name
- A String containing the name of the savepointjava.sql.SQLException
- if a database access error occurs or
this Connection object is currently in auto-commit modeprivate java.sql.Savepoint commonSetSavepointCode(java.lang.String name, boolean userSuppliedSavepointName) throws java.sql.SQLException
name
- A String containing the name of the savepoint. Will
be null if this is an unnamed savepointuserSuppliedSavepointName
- If true means it's a named
user defined savepoint.java.sql.SQLException
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
rollback
in interface java.sql.Connection
savepoint
- The Savepoint object to rollback tojava.sql.SQLException
- if a database access error occurs,
the Savepoint object is no longer valid, or this Connection
object is currently in auto-commit modepublic void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
releaseSavepoint
in interface java.sql.Connection
savepoint
- The Savepoint object to be removedjava.sql.SQLException
- if a database access error occurs or
the given Savepoint object is not a valid savepoint in the
current transactionprivate void verifySavepointCommandIsAllowed() throws java.sql.SQLException
java.sql.SQLException
private void verifySavepointArg(java.sql.Savepoint savepoint) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getSchema() throws java.sql.SQLException
getSchema
in interface java.sql.Connection
getSchema
in interface EngineConnection
java.sql.SQLException
public void setSchema(java.lang.String schemaName) throws java.sql.SQLException
setSchema
in interface java.sql.Connection
setSchema
in interface EngineConnection
java.sql.SQLException
private void checkConflictingCryptoAttributes(java.util.Properties p) throws java.sql.SQLException
p
- boot properties (for instance URL connection attributes)java.sql.SQLException
- if conflicting crypto attributes are detectedpublic java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException
createArrayOf
in interface java.sql.Connection
java.sql.SQLException
public java.sql.NClob createNClob() throws java.sql.SQLException
createNClob
in interface java.sql.Connection
java.sql.SQLException
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException
createSQLXML
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException
createStruct
in interface java.sql.Connection
java.sql.SQLException
public boolean isValid(int timeout) throws java.sql.SQLException
isValid
in interface java.sql.Connection
timeout
- This should be the time in seconds to wait for the
database operation used to validate the connection to complete
(according to the JDBC4 JavaDoc). This is currently not supported/used.java.sql.SQLException
- if the parameter value is illegal or if a
database error has occurredpublic void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoException
setClientInfo
will always throw a
SQLClientInfoException
since Derby does not support
any properties.setClientInfo
in interface java.sql.Connection
name
- a property key String
value
- a property value String
java.sql.SQLClientInfoException
- unless both name and value are nullpublic void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException
setClientInfo
will throw a
SQLClientInfoException
unless the properties
parameter is empty, since Derby does not support any
properties. All the property keys in the
properties
parameter are added to failedProperties
of the exception thrown, with REASON_UNKNOWN_PROPERTY as the
value.setClientInfo
in interface java.sql.Connection
properties
- a Properties
object with the
properties to setjava.sql.SQLClientInfoException
- unless properties parameter
is null or emptypublic java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException
getClientInfo
always returns a
null String
since Derby doesn't support
ClientInfoProperties.getClientInfo
in interface java.sql.Connection
name
- a String
valuenull String
valuejava.sql.SQLException
- if the connection is closed.public java.util.Properties getClientInfo() throws java.sql.SQLException
getClientInfo
always returns an empty
Properties
object since Derby doesn't support
ClientInfoProperties.getClientInfo
in interface java.sql.Connection
Properties
objectjava.sql.SQLException
- if the connection is closed.public final java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic boolean isWrapperFor(java.lang.Class<?> interfaces) throws java.sql.SQLException
interfaces
is implementedisWrapperFor
in interface java.sql.Wrapper
interfaces
- a Class defining an interface.java.sql.SQLException
- if an error occurs while determining
whether this is a wrapper for an object
with the given interface.public <T> T unwrap(java.lang.Class<T> interfaces) throws java.sql.SQLException
this
if this class implements the interfaceunwrap
in interface java.sql.Wrapper
interfaces
- a Class defining an interfacejava.sql.SQLException
- if no object is found that implements the
interfacepublic void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException
abort
in interface java.sql.Connection
abort
in interface EngineConnection
java.sql.SQLException
public int getNetworkTimeout() throws java.sql.SQLException
getNetworkTimeout
in interface java.sql.Connection
getNetworkTimeout
in interface EngineConnection
java.sql.SQLException
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException
setNetworkTimeout
in interface java.sql.Connection
setNetworkTimeout
in interface EngineConnection
java.sql.SQLException
static ModuleFactory getMonitor()
private static java.lang.Object findService(java.lang.String factoryInterface, java.lang.String serviceName)
private static boolean startPersistentService(java.lang.String serviceName, java.util.Properties properties) throws StandardException
StandardException
private static java.lang.Object createPersistentService(java.lang.String factoryInterface, java.lang.String serviceName, java.util.Properties properties) throws StandardException
StandardException
private static void removePersistentService(java.lang.String name) throws StandardException
StandardException
private LanguageConnectionContext privilegedGetLCC()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.