Class EmbedConnection
- java.lang.Object
-
- org.apache.derby.impl.jdbc.EmbedConnection
-
- All Implemented Interfaces:
- java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper, EngineConnection
public class EmbedConnection extends java.lang.Object implements EngineConnection
Local implementation of Connection for a JDBC driver in the same process as the database.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
- JDBC 4.2
- See Also:
TransactionResourceImpl
-
-
Field Summary
Fields Modifier and Type Field and Description static LowMemorymemoryStateLow memory state object for connection requests.static java.sql.SQLExceptionNO_MEMStatic exception to be thrown when a Connection request can not be fulfilled due to lack of memory.
-
Constructor Summary
Constructors 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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidabort(java.util.concurrent.Executor executor)intaddLOBMapping(java.lang.Object LOBReference)Add the locator and the corresponding LOB object into the HashMapvoidaddWarning(java.sql.SQLWarning newWarning)Add a warning to the current list of warnings, to follow this note from Connection.getWarnings.voidcancelRunningStatement()Cancels the current running statement.voidcheckForTransactionInProgress()Check if the transaction is active so that we cannot close down the connection.voidclearWarnings()After this call, getWarnings returns null until a new warning is reported for this Connection.voidclose()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.voidcommit()Commit makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.java.sql.ArraycreateArrayOf(java.lang.String typeName, java.lang.Object[] elements)java.sql.BlobcreateBlob()Constructs an object that implements theBlobinterface.java.sql.ClobcreateClob()Constructs an object that implements theClobinterface.java.sql.NClobcreateNClob()java.sql.SQLXMLcreateSQLXML()java.sql.StatementcreateStatement()SQL statements without parameters are normally executed using Statement objects.java.sql.StatementcreateStatement(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.StatementcreateStatement(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.StructcreateStruct(java.lang.String typeName, java.lang.Object[] attributes)java.sql.ConnectiongetApplicationConnection()booleangetAutoCommit()Get the current auto-commit state.java.lang.StringgetCatalog()Return the Connection's current catalog name.java.util.PropertiesgetClientInfo()getClientInfoalways returns an emptyPropertiesobject since Derby doesn't support ClientInfoProperties.java.lang.StringgetClientInfo(java.lang.String name)getClientInfoalways returns anull Stringsince Derby doesn't support ClientInfoProperties.ContextManagergetContextManager()Return the context manager for this connection.java.lang.StringgetCurrentSchemaName()Obtain the name of the current schema.java.lang.StringgetDBName()Return the dbname for this connection.intgetEngineType()Gets the EngineType of the connected database.intgetHoldability()JDBC 3.0 Retrieves the current holdability of ResultSet objects created using this Connection object.LanguageConnectionContextgetLanguageConnection()java.lang.ObjectgetLOBMapping(int key)Get the LOB reference corresponding to the locator.InternalDrivergetLocalDriver()java.sql.DatabaseMetaDatagetMetaData()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.intgetNetworkTimeout()intgetPrepareIsolation()Return prepare isolationjava.lang.StringgetSchema()Get the name of the current schema.intgetTransactionIsolation()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.SQLWarninggetWarnings()The first warning reported by calls on this Connection is returned.booleanisAborting()Return true if the connection is abortingbooleanisClosed()Tests to see if a Connection is closed.booleanisInGlobalTransaction()Is this a global transactionbooleanisReadOnly()Tests to see if the connection is in read-only mode.booleanisValid(int timeout)Checks if the connection has not been closed and is still valid.booleanisWrapperFor(java.lang.Class<?> interfaces)Returns false unlessinterfacesis implementedjava.lang.StringnativeSQL(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.java.sql.CallableStatementprepareCall(java.lang.String sql)A SQL stored procedure call statement is handled by creating a CallableStatement for it.java.sql.CallableStatementprepareCall(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.CallableStatementprepareCall(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.java.sql.PreparedStatementprepareStatement(java.lang.String sql)A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)Creates a default PreparedStatement object that has the capability to retieve auto-generated keys.java.sql.PreparedStatementprepareStatement(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.PreparedStatementprepareStatement(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.PreparedStatementprepareStatement(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.java.sql.PreparedStatementprepareStatement(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.voidreleaseSavepoint(java.sql.Savepoint savepoint)Removes the given Savepoint object from the current transaction.voidremoveLOBMapping(int key)Remove the key(LOCATOR) from the hash table.voidresetFromPool()Reset the connection before it is returned from a PooledConnection to a new application request (wrapped by a BrokeredConnection).voidrollback()Rollback drops all changes made since the previous commit/rollback and releases any database locks currently held by the Connection.voidrollback(java.sql.Savepoint savepoint)Undoes all changes made after the given Savepoint object was set.voidsetApplicationConnection(java.sql.Connection applicationConnection)voidsetAutoCommit(boolean autoCommit)If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions.voidsetCatalog(java.lang.String catalog)A sub-space of this Connection's database may be selected by setting a catalog name.voidsetClientInfo(java.util.Properties properties)setClientInfowill throw aSQLClientInfoExceptionunless thepropertiesparameter is empty, since Derby does not support any properties.voidsetClientInfo(java.lang.String name, java.lang.String value)setClientInfowill always throw aSQLClientInfoExceptionsince Derby does not support any properties.voidsetDrdaID(java.lang.String drdaID)Set the DRDA identifier for this connection.voidsetHoldability(int holdability)JDBC 3.0 Changes the holdability of ResultSet objects created using this Connection object to the given holdability.voidsetInactive()Close the connection when processing errors, or when closing a nested connection.voidsetNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)voidsetPrepareIsolation(int level)Set the transaction isolation level that will be used for the next prepare.voidsetReadOnly(boolean readOnly)You can put a connection in read-only mode as a hint to enable database optimizations.java.sql.SavepointsetSavepoint()Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.java.sql.SavepointsetSavepoint(java.lang.String name)Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.voidsetSchema(java.lang.String schemaName)Set the default schema for the Connection.voidsetTransactionIsolation(int level)You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values.voidsetTypeMap(java.util.Map map)Install a type-map object as the default type-map for this connection.static java.lang.StringstripSubSubProtocolPrefix(java.lang.String dbname)Strips any sub-sub-protocol prefix from a database name.java.lang.StringtoString()Get a String representation that uniquely identifies this connection.booleantransactionIsIdle()returns false if there is an underlying transaction and that transaction has done work.<T> Tunwrap(java.lang.Class<T> interfaces)Returnsthisif this class implements the interfacevoidxa_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.intxa_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.voidxa_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.
-
-
-
Field Detail
-
NO_MEM
public static final java.sql.SQLException NO_MEM
Static exception to be thrown when a Connection request can not be fulfilled due to lack of memory. A static exception as the lack of memory would most likely cause another OutOfMemoryException and if there is not enough memory to create the OOME exception then something like the VM dying could occur. Simpler just to throw a static.
-
memoryState
public static final LowMemory memoryState
Low memory state object for connection requests.
-
-
Constructor Detail
-
EmbedConnection
public EmbedConnection(InternalDriver driver, java.lang.String url, java.util.Properties info) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
EmbedConnection
public EmbedConnection(EmbedConnection inputConnection)
Create a new connection based off of the connection passed in. Initializes state based on input connection, and copies appropriate object pointers. This is only used for nested connections.- Parameters:
inputConnection- the input connection
-
-
Method Detail
-
getEngineType
public int getEngineType()
Gets the EngineType of the connected database.- Returns:
- 0 if there is no database, the engine type otherwise. @see org.apache.derby.iapi.reference.EngineType
-
createStatement
public final java.sql.Statement createStatement() throws java.sql.SQLExceptionSQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement JDBC 2.0 Result sets created using the returned Statement will have forward-only type, and read-only concurrency, by default.- Specified by:
createStatementin interfacejava.sql.Connection- Returns:
- a new Statement object
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
createStatement
public final java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionJDBC 2.0 Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden.- Specified by:
createStatementin interfacejava.sql.Connection- Parameters:
resultSetType- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency- a concurrency type, see ResultSet.CONCUR_XXX- Returns:
- a new Statement object
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
createStatement
public final java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionJDBC 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.- Specified by:
createStatementin interfacejava.sql.Connection- Parameters:
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_COMMIT- Returns:
- a new Statement object
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLExceptionA SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.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.
- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- a SQL statement that may contain one or more '?' IN parameter placeholders- Returns:
- a new PreparedStatement object containing the pre-compiled statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionJDBC 2.0 Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden.- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
resultSetType- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency- a concurrency type, see ResultSet.CONCUR_XXX- Returns:
- a new PreparedStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionJDBC 3.0 Same as prepareStatement() above, but allows the default result set type, result set concurrency type and result set holdability to be overridden.- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
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_COMMIT- Returns:
- a new PreparedStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLExceptionCreates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. This array is ignored if the SQL statement is not an INSERT statement JDBC 3.0- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
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 rows- Returns:
- A new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys designated by the given array of column indexes
- Throws:
java.sql.SQLException- Thrown on error.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLExceptionCreates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. This array is ignored if the SQL statement is not an INSERT statement JDBC 3.0- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
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 rows- Returns:
- A new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys designated by the given array of column names
- Throws:
java.sql.SQLException- Thrown on error.
-
prepareStatement
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLExceptionCreates a default PreparedStatement object that has the capability to retieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERT statement. JDBC 3.0- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- A SQL statement that may contain one or more ? IN parameter placeholdersautoGeneratedKeys- A flag indicating whether auto-generated keys should be returned- Returns:
- A new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys
- Throws:
java.sql.SQLException- Feature not implemented for now.
-
prepareCall
public final java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLExceptionA SQL stored procedure call statement is handled by creating a CallableStatement for it. The CallableStatement provides methods for setting up its IN and OUT parameters, and methods for executing it.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.
- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
sql- a SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is a JDBC function call escape string.- Returns:
- a new CallableStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareCall
public final java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionJDBC 2.0 Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden.- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
resultSetType- a result set type, see ResultSet.TYPE_XXXresultSetConcurrency- a concurrency type, see ResultSet.CONCUR_XXX- Returns:
- a new CallableStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
prepareCall
public final java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionJDBC 3.0 Same as prepareCall() above, but allows the default result set type, result set concurrency type and result set holdability to be overridden.- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
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_COMMIT- Returns:
- a new CallableStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLExceptionA 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.- Specified by:
nativeSQLin interfacejava.sql.Connection- Parameters:
sql- a SQL statement that may contain one or more '?' parameter placeholders- Returns:
- the native form of this statement
- Throws:
java.sql.SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLExceptionIf a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by either commit() or rollback(). By default, new connections are in auto-commit mode. The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. Here the commit occurs when all results and output param values have been retrieved.- Specified by:
setAutoCommitin interfacejava.sql.Connection- Parameters:
autoCommit- true enables auto-commit; false disables auto-commit.- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLExceptionGet the current auto-commit state.- Specified by:
getAutoCommitin interfacejava.sql.Connection- Returns:
- Current state of auto-commit mode.
- Throws:
java.sql.SQLException- See Also:
setAutoCommit(boolean)
-
commit
public void commit() throws java.sql.SQLExceptionCommit makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should only be used when auto commit has been disabled.- Specified by:
commitin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database-access error occurs.- See Also:
setAutoCommit(boolean)
-
rollback
public void rollback() throws java.sql.SQLExceptionRollback drops all changes made since the previous commit/rollback and releases any database locks currently held by the Connection. This method should only be used when auto commit has been disabled.- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database-access error occurs.- See Also:
setAutoCommit(boolean)
-
close
public void close() throws java.sql.SQLExceptionIn 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.Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database-access error occurs.
-
checkForTransactionInProgress
public void checkForTransactionInProgress() throws java.sql.SQLExceptionCheck if the transaction is active so that we cannot close down the connection. If auto-commit is on, the transaction is committed when the connection is closed, so it is always OK to close the connection in that case. Otherwise, throw an exception if a transaction is in progress.- Throws:
java.sql.SQLException- if this transaction is active and the connection cannot be closed
-
isClosed
public final boolean isClosed()
Tests to see if a Connection is closed.- Specified by:
isClosedin interfacejava.sql.Connection- Returns:
- true if the connection is closed; false if it's still open
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLExceptionA Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is made available through a DatabaseMetaData object.- Specified by:
getMetaDatain interfacejava.sql.Connection- Returns:
- a DatabaseMetaData object for this Connection
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getHoldability
public final int getHoldability() throws java.sql.SQLExceptionJDBC 3.0 Retrieves the current holdability of ResultSet objects created using this Connection object.- Specified by:
getHoldabilityin interfacejava.sql.Connection- Returns:
- The holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
- Throws:
java.sql.SQLException
-
setHoldability
public final void setHoldability(int holdability) throws java.sql.SQLExceptionJDBC 3.0 Changes the holdability of ResultSet objects created using this Connection object to the given holdability.- Specified by:
setHoldabilityin interfacejava.sql.Connection- Parameters:
holdability- A ResultSet holdability constant, one of ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT- Throws:
java.sql.SQLException
-
setReadOnly
public final void setReadOnly(boolean readOnly) throws java.sql.SQLExceptionYou can put a connection in read-only mode as a hint to enable database optimizations.Note: setReadOnly cannot be called while in the middle of a transaction.
- Specified by:
setReadOnlyin interfacejava.sql.Connection- Parameters:
readOnly- true enables read-only mode; false disables read-only mode.- Throws:
java.sql.SQLException- if a database-access error occurs.
-
isReadOnly
public final boolean isReadOnly() throws java.sql.SQLExceptionTests to see if the connection is in read-only mode.- Specified by:
isReadOnlyin interfacejava.sql.Connection- Returns:
- true if connection is read-only
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLExceptionA sub-space of this Connection's database may be selected by setting a catalog name. If the driver does not support catalogs it will silently ignore this request.- Specified by:
setCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLExceptionReturn the Connection's current catalog name.- Specified by:
getCatalogin interfacejava.sql.Connection- Returns:
- the current catalog name or null
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLExceptionYou can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values.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.
- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Parameters:
level- one of the TRANSACTION_* isolation values with the exception of TRANSACTION_NONE; some databases may not support other values- Throws:
java.sql.SQLException- if a database-access error occurs.- See Also:
DatabaseMetaData.supportsTransactionIsolationLevel(int)
-
getTransactionIsolation
public final int getTransactionIsolation() throws java.sql.SQLExceptionGet this Connection's current transaction isolation mode.- Specified by:
getTransactionIsolationin interfacejava.sql.Connection- Returns:
- the current TRANSACTION_* mode value
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getWarnings
public final java.sql.SQLWarning getWarnings() throws java.sql.SQLExceptionThe first warning reported by calls on this Connection is returned.Note: Subsequent warnings will be chained to this SQLWarning.
- Specified by:
getWarningsin interfacejava.sql.Connection- Returns:
- the first SQLWarning or null Synchronization note: Warnings are synchronized on nesting level
- Throws:
java.sql.SQLException
-
clearWarnings
public final void clearWarnings() throws java.sql.SQLExceptionAfter this call, getWarnings returns null until a new warning is reported for this Connection. Synchronization node: Warnings are synchonized on nesting level- Specified by:
clearWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTypeMap
public final void setTypeMap(java.util.Map map) throws java.sql.SQLExceptionInstall a type-map object as the default type-map for this connection. JDBC 2.0 - java.util.Map requires JDK 1- Specified by:
setTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException- Feature not implemented for now.
-
addWarning
public final void addWarning(java.sql.SQLWarning newWarning)
Add a warning to the current list of warnings, to follow this note from Connection.getWarnings. Note: Subsequent warnings will be chained to this SQLWarning.- Specified by:
addWarningin interfaceEngineConnection- Parameters:
newWarning- Warning to be added, will be chained to any existing warnings.- See Also:
Connection.getWarnings()
-
getDBName
public java.lang.String getDBName()
Return the dbname for this connection.- Returns:
- String The dbname for this connection.
-
getLanguageConnection
public final LanguageConnectionContext getLanguageConnection()
-
setInactive
public final void setInactive()
Close the connection when processing errors, or when closing a nested connection.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().
-
stripSubSubProtocolPrefix
public static java.lang.String stripSubSubProtocolPrefix(java.lang.String dbname)
Strips any sub-sub-protocol prefix from a database name.- Parameters:
dbname- a database name- Returns:
- the database name without any sub-sub-protocol prefixes
- Throws:
java.lang.NullPointerException- if dbname is null
-
getLocalDriver
public final InternalDriver getLocalDriver()
-
getContextManager
public final ContextManager getContextManager()
Return the context manager for this connection.
-
setApplicationConnection
public final void setApplicationConnection(java.sql.Connection applicationConnection)
-
getApplicationConnection
public final java.sql.Connection getApplicationConnection()
-
setDrdaID
public void setDrdaID(java.lang.String drdaID)
Description copied from interface:EngineConnectionSet the DRDA identifier for this connection.- Specified by:
setDrdaIDin interfaceEngineConnection
-
isInGlobalTransaction
public boolean isInGlobalTransaction()
Description copied from interface:EngineConnectionIs this a global transaction- Specified by:
isInGlobalTransactionin interfaceEngineConnection- Returns:
- true if this is a global XA transaction
- See Also:
EngineConnection.isInGlobalTransaction()
-
resetFromPool
public void resetFromPool() throws java.sql.SQLExceptionReset the connection before it is returned from a PooledConnection to a new application request (wrapped by a BrokeredConnection). Examples of reset covered here is dropping session temporary tables and reseting IDENTITY_VAL_LOCAL. Most JDBC level reset is handled by calling standard java.sql.Connection methods from EmbedPooledConnection.- Specified by:
resetFromPoolin interfaceEngineConnection- Throws:
java.sql.SQLException
-
xa_prepare
public final int xa_prepare() throws java.sql.SQLExceptionDo 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.- Returns:
- One of
XATransactionController.XA_OKorXATransactionController.XA_RDONLY - Throws:
java.sql.SQLException
-
xa_commit
public final void xa_commit(boolean onePhase) throws java.sql.SQLExceptionDo 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.- Throws:
java.sql.SQLException
-
xa_rollback
public final void xa_rollback() throws java.sql.SQLExceptionDo 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.- Throws:
java.sql.SQLException
-
transactionIsIdle
public final boolean transactionIsIdle()
returns false if there is an underlying transaction and that transaction has done work. True if there is no underlying transaction or that underlying transaction is idle
-
setPrepareIsolation
public void setPrepareIsolation(int level) throws java.sql.SQLExceptionSet the transaction isolation level that will be used for the next prepare. Used by network server to implement DB2 style isolation levels.- Specified by:
setPrepareIsolationin interfaceEngineConnection- Parameters:
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.- Throws:
java.sql.SQLException
-
getPrepareIsolation
public int getPrepareIsolation()
Return prepare isolation- Specified by:
getPrepareIsolationin interfaceEngineConnection
-
toString
public java.lang.String toString()
Get a String representation that uniquely identifies this connection. Include the same information that is printed in the log for various trace and error messages. In Derby the "physical" connection is a LanguageConnectionContext, or LCC. The JDBC Connection is an JDBC-specific layer on top of this. Rather than create a new id here, we simply use the id of the underlying LCC. Note that this is a big aid in debugging, because much of the engine trace and log code prints the LCC id.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation for this connection
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLExceptionConstructs an object that implements theClobinterface. The object returned initially contains no data. ThesetAsciiStream,setCharacterStreamandsetStringmethods of theClobinterface may be used to add data to theClob.- Specified by:
createClobin interfacejava.sql.Connection- Returns:
- An object that implements the
Clobinterface - Throws:
java.sql.SQLException- if an object that implements theClobinterface can not be constructed, this method is called on a closed connection or a database access error occurs.
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLExceptionConstructs an object that implements theBlobinterface. The object returned initially contains no data. ThesetBinaryStreamandsetBytesmethods of theBlobinterface may be used to add data to theBlob.- Specified by:
createBlobin interfacejava.sql.Connection- Returns:
- An object that implements the
Blobinterface - Throws:
java.sql.SQLException- if an object that implements theBlobinterface can not be constructed, this method is called on a closed connection or a database access error occurs.
-
addLOBMapping
public int addLOBMapping(java.lang.Object LOBReference)
Add the locator and the corresponding LOB object into the HashMap- Parameters:
LOBReference- The object which contains the LOB object that that is added to the HashMap.- Returns:
- an integer that represents the locator that has been allocated to this LOB.
-
removeLOBMapping
public void removeLOBMapping(int key)
Remove the key(LOCATOR) from the hash table.- Parameters:
key- an integer that represents the locator that needs to be removed from the table.
-
getLOBMapping
public java.lang.Object getLOBMapping(int key)
Get the LOB reference corresponding to the locator.- Specified by:
getLOBMappingin interfaceEngineConnection- Parameters:
key- the integer that represents the LOB locator value.- Returns:
- the LOB Object corresponding to this locator.
-
cancelRunningStatement
public void cancelRunningStatement()
Cancels the current running statement.
-
getCurrentSchemaName
public java.lang.String getCurrentSchemaName()
Obtain the name of the current schema. Not part of the java.sql.Connection interface, but is accessible through the EngineConnection interface, so that the NetworkServer can get at the current schema for piggy-backing- Specified by:
getCurrentSchemaNamein interfaceEngineConnection- Returns:
- the current schema name
-
isAborting
public boolean isAborting()
Return true if the connection is aborting
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLExceptionCreates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.- Specified by:
setSavepointin interfacejava.sql.Connection- Returns:
- The new Savepoint object
- Throws:
java.sql.SQLException- if a database access error occurs or this Connection object is currently in auto-commit mode
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLExceptionCreates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.- Specified by:
setSavepointin interfacejava.sql.Connection- Parameters:
name- A String containing the name of the savepoint- Returns:
- The new Savepoint object
- Throws:
java.sql.SQLException- if a database access error occurs or this Connection object is currently in auto-commit mode
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLExceptionUndoes all changes made after the given Savepoint object was set. This method should be used only when auto-commit has been disabled.- Specified by:
rollbackin interfacejava.sql.Connection- Parameters:
savepoint- The Savepoint object to rollback to- Throws:
java.sql.SQLException- if a database access error occurs, the Savepoint object is no longer valid, or this Connection object is currently in auto-commit mode
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLExceptionRemoves the given Savepoint object from the current transaction. Any reference to the savepoint after it has been removed will cause an SQLException to be thrown- Specified by:
releaseSavepointin interfacejava.sql.Connection- Parameters:
savepoint- The Savepoint object to be removed- Throws:
java.sql.SQLException- if a database access error occurs or the given Savepoint object is not a valid savepoint in the current transaction
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLExceptionGet the name of the current schema.- Specified by:
getSchemain interfacejava.sql.Connection- Specified by:
getSchemain interfaceEngineConnection- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schemaName) throws java.sql.SQLExceptionSet the default schema for the Connection.- Specified by:
setSchemain interfacejava.sql.Connection- Specified by:
setSchemain interfaceEngineConnection- Throws:
java.sql.SQLException
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException- Specified by:
createArrayOfin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException- Specified by:
createNClobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException- Specified by:
createSQLXMLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException- Specified by:
createStructin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLExceptionChecks if the connection has not been closed and is still valid. The validity is checked by checking that the connection is not closed.- Specified by:
isValidin interfacejava.sql.Connection- Parameters:
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.- Returns:
- true if the connection is valid, false otherwise
- Throws:
java.sql.SQLException- if the parameter value is illegal or if a database error has occurred
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoExceptionsetClientInfowill always throw aSQLClientInfoExceptionsince Derby does not support any properties.- Specified by:
setClientInfoin interfacejava.sql.Connection- Parameters:
name- a property keyStringvalue- a property valueString- Throws:
java.sql.SQLClientInfoException- unless both name and value are null
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoExceptionsetClientInfowill throw aSQLClientInfoExceptionunless thepropertiesparameter is empty, since Derby does not support any properties. All the property keys in thepropertiesparameter are added to failedProperties of the exception thrown, with REASON_UNKNOWN_PROPERTY as the value.- Specified by:
setClientInfoin interfacejava.sql.Connection- Parameters:
properties- aPropertiesobject with the properties to set- Throws:
java.sql.SQLClientInfoException- unless properties parameter is null or empty
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLExceptiongetClientInfoalways returns anull Stringsince Derby doesn't support ClientInfoProperties.- Specified by:
getClientInfoin interfacejava.sql.Connection- Parameters:
name- aStringvalue- Returns:
- a
null Stringvalue - Throws:
java.sql.SQLException- if the connection is closed.
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLExceptiongetClientInfoalways returns an emptyPropertiesobject since Derby doesn't support ClientInfoProperties.- Specified by:
getClientInfoin interfacejava.sql.Connection- Returns:
- an empty
Propertiesobject - Throws:
java.sql.SQLException- if the connection is closed.
-
getTypeMap
public final java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLExceptionReturns the type map for this connection.- Specified by:
getTypeMapin interfacejava.sql.Connection- Returns:
- type map for this connection
- Throws:
java.sql.SQLException- if a database access error occurs
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> interfaces) throws java.sql.SQLExceptionReturns false unlessinterfacesis implemented- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Parameters:
interfaces- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
- Throws:
java.sql.SQLException- if an error occurs while determining whether this is a wrapper for an object with the given interface.
-
unwrap
public <T> T unwrap(java.lang.Class<T> interfaces) throws java.sql.SQLExceptionReturnsthisif this class implements the interface- Specified by:
unwrapin interfacejava.sql.Wrapper- Parameters:
interfaces- a Class defining an interface- Returns:
- an object that implements the interface
- Throws:
java.sql.SQLException- if no object is found that implements the interface
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Specified by:
abortin interfaceEngineConnection- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection- Specified by:
getNetworkTimeoutin interfaceEngineConnection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Specified by:
setNetworkTimeoutin interfaceEngineConnection- Throws:
java.sql.SQLException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG