Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.jdbc
Class EmbedConnection  view EmbedConnection download EmbedConnection.java

java.lang.Object
  extended byorg.apache.derby.impl.jdbc.EmbedConnection
All Implemented Interfaces:
java.sql.Connection
Direct Known Subclasses:
EmbedConnection30

public class EmbedConnection
extends java.lang.Object
implements java.sql.Connection

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


Field Summary
private  boolean active
           
private  java.sql.Connection applicationConnection
          The Connection object the application is using when accessing the database through this connection.
protected  boolean autoCommit
           
protected  int connectionHoldAbility
           
protected  java.sql.DatabaseMetaData dbMetadata
           
private static org.apache.derby.iapi.error.StandardException exceptionClose
           
 org.apache.derby.jdbc.InternalDriver factory
          Factory for JDBC objects to be created.
private  java.lang.String idString
          Cached string representation of the connection id
(package private)  boolean needCommit
           
private  int resultSetId
          An increasing counter to assign to a ResultSet on its creation.
protected  EmbedConnection rootConnection
           
private  java.sql.SQLWarning topWarning
           
protected  TransactionResourceImpl tr
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
EmbedConnection(EmbedConnection inputConnection)
          Create a new connection based off of the connection passed in.
EmbedConnection(org.apache.derby.jdbc.InternalDriver driver, java.lang.String url, java.util.Properties info)
           
 
Method Summary
 void addWarning(java.sql.SQLWarning newWarning)
          Add a warning to the current list of warnings, to follow this note from Connection.getWarnings.
private  boolean bootDatabase(java.util.Properties info)
          Return false iff the monitor cannot handle a service of the type indicated by the protocol within the name.
private  void checkUserCredentials(java.lang.String dbname, java.util.Properties userInfo)
           
 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.
private  void close(java.lang.Exception 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  boolean createBoot(java.util.Properties p)
          Examine the attributes set provided and determine if this is a create boot.
private  org.apache.derby.iapi.db.Database createDatabase(java.lang.String dbname, java.util.Properties info)
          Create a new database.
 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.
private  java.util.Properties filterProperties(java.util.Properties inputSet)
           
protected  void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
 java.sql.Connection getApplicationConnection()
           
 boolean getAutoCommit()
          Get the current auto-commit state.
 java.lang.String getCatalog()
          Return the Connection's current catalog name.
protected  java.lang.Object getConnectionSynchronization()
           
 org.apache.derby.iapi.services.context.ContextManager getContextManager()
          Return the context manager for this connection.
protected  org.apache.derby.iapi.db.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.
 org.apache.derby.iapi.sql.conn.LanguageConnectionContext getLanguageConnection()
           
 org.apache.derby.jdbc.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.
 int getPrepareIsolation()
          Return prepare isolation
(package private)  int getResultSetOrderId()
          Return a unique order number for a result set.
protected  TransactionResourceImpl getTR()
           
 int getTransactionIsolation()
          Get this Connection's current transaction isolation mode.
 java.util.Map getTypeMap()
          Get the type-map object associated with this connection.
 java.sql.SQLWarning getWarnings()
          The first warning reported by calls on this Connection is returned.
 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.
 boolean isClosed()
          Tests to see if a Connection is closed.
 boolean isReadOnly()
          Tests to see if the connection is in read-only mode.
 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.
protected  java.sql.SQLException newSQLException(java.lang.String messageId)
           
protected  java.sql.SQLException newSQLException(java.lang.String messageId, java.lang.Object arg1)
           
protected  java.sql.SQLException newSQLException(java.lang.String messageId, java.lang.Object arg1, java.lang.Object arg2)
           
 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  EmbedConnectionContext pushConnectionContext(org.apache.derby.iapi.services.context.ContextManager cm)
           
 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 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 setDrdaID(java.lang.String drdaID)
           
 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 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 setResultSetConcurrency(int resultSetType, int resultSetConcurrency)
           
private  int setResultSetType(int resultSetType)
           
 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.
 java.lang.String toString()
          Get a String representation that uniquely identifies this connection In Derby the "physical" connection is a LanguageConnectionContext, or LCC.
 boolean transactionIsIdle()
          returns false if there is an underlying transaction and that transaction has done work.
 void xa_commit(boolean onePhase)
           
 int xa_prepare()
           
 void xa_rollback()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
releaseSavepoint, rollback, setSavepoint, setSavepoint
 

Field Detail

exceptionClose

private static final org.apache.derby.iapi.error.StandardException exceptionClose

dbMetadata

protected java.sql.DatabaseMetaData dbMetadata

tr

protected final TransactionResourceImpl tr

active

private boolean active

autoCommit

protected boolean autoCommit

needCommit

boolean needCommit

connectionHoldAbility

protected int connectionHoldAbility

rootConnection

protected final EmbedConnection rootConnection

topWarning

private java.sql.SQLWarning topWarning

factory

public org.apache.derby.jdbc.InternalDriver factory
Factory for JDBC objects to be created.


applicationConnection

private java.sql.Connection applicationConnection
The Connection object the application is using when accessing the database through this connection. In most cases this will be equal to this. When Connection pooling is being used, then it will be set to the Connection object handed to the application. It is used for the getConnection() methods of various JDBC objects.


resultSetId

private int resultSetId
An increasing counter to assign to a ResultSet on its creation. Used for ordering ResultSets returned from a procedure, always returned in order of their creation. Is maintained at the root connection.


idString

private java.lang.String idString
Cached string representation of the connection id

Constructor Detail

EmbedConnection

public EmbedConnection(org.apache.derby.jdbc.InternalDriver driver,
                       java.lang.String url,
                       java.util.Properties info)
                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.

Method Detail

createBoot

private boolean createBoot(java.util.Properties p)
                    throws java.sql.SQLException
Examine the attributes set provided and determine if this is a create boot. A boot is a create boot iff.
  1. create=true - This means create a standard database.
  2. createFrom = Path - creates database from backup if it does not exist.
  3. restoreFrom = Path - database is restored completley from backup. if a database exists in the same place it is replaced by the version in the backup otherwise a new one is created using the backup copy.
  4. rollForwardRecoveryFrom = Path - rollforward is performed using the version backup and any active and archived log files.


checkUserCredentials

private void checkUserCredentials(java.lang.String dbname,
                                  java.util.Properties userInfo)
                           throws java.sql.SQLException

getEngineType

public int getEngineType()
Gets the EngineType of the connected database.


createStatement

public final java.sql.Statement createStatement()
                                         throws java.sql.SQLException
SQL 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:
createStatement in interface java.sql.Connection

createStatement

public final java.sql.Statement createStatement(int resultSetType,
                                                int resultSetConcurrency)
                                         throws java.sql.SQLException
JDBC 2.0 Same as createStatement() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
createStatement in interface java.sql.Connection

createStatement

public final java.sql.Statement createStatement(int resultSetType,
                                                int resultSetConcurrency,
                                                int resultSetHoldability)
                                         throws java.sql.SQLException
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.

Specified by:
createStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                                  throws java.sql.SQLException
A 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:
prepareStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int resultSetType,
                                                         int resultSetConcurrency)
                                                  throws java.sql.SQLException
JDBC 2.0 Same as prepareStatement() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
prepareStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int resultSetType,
                                                         int resultSetConcurrency,
                                                         int resultSetHoldability)
                                                  throws java.sql.SQLException
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.

Specified by:
prepareStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int[] columnIndexes)
                                                  throws java.sql.SQLException
Creates 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:
prepareStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         java.lang.String[] columnNames)
                                                  throws java.sql.SQLException
Creates 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:
prepareStatement in interface java.sql.Connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int autoGeneratedKeys)
                                                  throws java.sql.SQLException
Creates 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:
prepareStatement in interface java.sql.Connection

prepareStatement

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

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql)
                                             throws java.sql.SQLException
A 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:
prepareCall in interface java.sql.Connection

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql,
                                                    int resultSetType,
                                                    int resultSetConcurrency)
                                             throws java.sql.SQLException
JDBC 2.0 Same as prepareCall() above, but allows the default result set type and result set concurrency type to be overridden.

Specified by:
prepareCall in interface java.sql.Connection

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql,
                                                    int resultSetType,
                                                    int resultSetConcurrency,
                                                    int resultSetHoldability)
                                             throws java.sql.SQLException
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.

Specified by:
prepareCall in interface java.sql.Connection

nativeSQL

public 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.

Specified by:
nativeSQL in interface java.sql.Connection

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
If 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:
setAutoCommit in interface java.sql.Connection

getAutoCommit

public boolean getAutoCommit()
Get the current auto-commit state.

Specified by:
getAutoCommit in interface java.sql.Connection

commit

public void commit()
            throws java.sql.SQLException
Commit 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:
commit in interface java.sql.Connection

rollback

public void rollback()
              throws java.sql.SQLException
Rollback 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:
rollback in interface java.sql.Connection

close

public void close()
           throws java.sql.SQLException
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.

Note: A Connection is automatically closed when it is garbage collected. Certain fatal errors also result in a closed Connection.

Specified by:
close in interface java.sql.Connection

close

private void close(java.lang.Exception e)
            throws java.sql.SQLException

isClosed

public final boolean isClosed()
Tests to see if a Connection is closed.

Specified by:
isClosed in interface java.sql.Connection

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws java.sql.SQLException
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. This information is made available through a DatabaseMetaData object.

Specified by:
getMetaData in interface java.sql.Connection

getHoldability

public final int getHoldability()
JDBC 3.0 Retrieves the current holdability of ResultSet objects created using this Connection object.

Specified by:
getHoldability in interface java.sql.Connection

setHoldability

public final void setHoldability(int holdability)
JDBC 3.0 Changes the holdability of ResultSet objects created using this Connection object to the given holdability.

Specified by:
setHoldability in interface java.sql.Connection

setReadOnly

public final void setReadOnly(boolean readOnly)
                       throws java.sql.SQLException
You 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:
setReadOnly in interface java.sql.Connection

isReadOnly

public final boolean isReadOnly()
                         throws java.sql.SQLException
Tests to see if the connection is in read-only mode.

Specified by:
isReadOnly in interface java.sql.Connection

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
A 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:
setCatalog in interface java.sql.Connection

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Return the Connection's current catalog name.

Specified by:
getCatalog in interface java.sql.Connection

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
You 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

Specified by:
setTransactionIsolation in interface java.sql.Connection

getTransactionIsolation

public final int getTransactionIsolation()
                                  throws java.sql.SQLException
Get this Connection's current transaction isolation mode.

Specified by:
getTransactionIsolation in interface java.sql.Connection

getWarnings

public final java.sql.SQLWarning getWarnings()
The first warning reported by calls on this Connection is returned.

Note: Subsequent warnings will be chained to this SQLWarning.

Specified by:
getWarnings in interface java.sql.Connection

clearWarnings

public final void clearWarnings()
After this call, getWarnings returns null until a new warning is reported for this Connection. Synchronization node: Warnings are synchonized on nesting level

Specified by:
clearWarnings in interface java.sql.Connection

getTypeMap

public final java.util.Map getTypeMap()
Get the type-map object associated with this connection. By default, the map returned is empty. JDBC 2.0 - java.util.Map requires JDK 1

Specified by:
getTypeMap in interface java.sql.Connection

setTypeMap

public final void setTypeMap(java.util.Map map)
                      throws java.sql.SQLException
Install a type-map object as the default type-map for this connection. JDBC 2.0 - java.util.Map requires JDK 1

Specified by:
setTypeMap in interface java.sql.Connection

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.


getDBName

public java.lang.String getDBName()
Return the dbname for this connection.


getLanguageConnection

public final org.apache.derby.iapi.sql.conn.LanguageConnectionContext getLanguageConnection()

handleException

public java.sql.SQLException handleException(java.lang.Throwable thrownException)
                                      throws java.sql.SQLException

handleException

final java.sql.SQLException handleException(java.lang.Throwable thrownException,
                                            boolean rollbackOnAutoCommit)
                                     throws java.sql.SQLException
Handle any type of Exception.
  • Inform the contexts of the error
  • Throw an Util based upon the thrown exception.
REMIND: now that we know all the exceptions from our driver are Utils, would it make sense to shut down the system for unknown SQLExceptions? At present, we do not. Because this is the last stop for exceptions, it will catch anything that occurs in it and try to cleanup before re-throwing them.


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().


finalize

protected void finalize()
                 throws java.lang.Throwable
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


needCommit

protected void needCommit()
if auto commit is on, remember that we need to commit the current statement.


commitIfNeeded

protected void commitIfNeeded()
                       throws java.sql.SQLException
if a commit is needed, perform it. Must have connection synchonization and context set up already.


commitIfAutoCommit

protected void commitIfAutoCommit()
                           throws java.sql.SQLException
If in autocommit, then commit. Used to force a commit after a result set closes in autocommit mode. The needCommit mechanism does not work correctly as there are times with cursors (like a commit, followed by a next, followed by a close) where the system does not think it needs a commit but we need to force the commit on close. It seemed safer to just force a commit on close rather than count on keeping the needCommit flag correct for all cursor cases. Must have connection synchonization and context set up already.


getConnectionSynchronization

protected final java.lang.Object getConnectionSynchronization()

setupContextStack

protected final void setupContextStack()
                                throws java.sql.SQLException
Install the context manager for this thread. Check connection status here.


restoreContextStack

protected final void restoreContextStack()
                                  throws java.sql.SQLException

createDatabase

private org.apache.derby.iapi.db.Database createDatabase(java.lang.String dbname,
                                                         java.util.Properties info)
                                                  throws java.sql.SQLException
Create a new database.


bootDatabase

private boolean bootDatabase(java.util.Properties info)
                      throws java.lang.Throwable
Return false iff the monitor cannot handle a service of the type indicated by the protocol within the name. If that's the case then we are the wrong driver. Throw exception if anything else is wrong.


prepareMetaDataStatement

java.sql.PreparedStatement prepareMetaDataStatement(java.lang.String sql)
                                              throws java.sql.SQLException

getLocalDriver

public final org.apache.derby.jdbc.InternalDriver getLocalDriver()

getContextManager

public final org.apache.derby.iapi.services.context.ContextManager getContextManager()
Return the context manager for this connection.


filterProperties

private java.util.Properties filterProperties(java.util.Properties inputSet)

getDatabase

protected org.apache.derby.iapi.db.Database getDatabase()

getTR

protected final TransactionResourceImpl getTR()

pushConnectionContext

private EmbedConnectionContext pushConnectionContext(org.apache.derby.iapi.services.context.ContextManager cm)

setApplicationConnection

public final void setApplicationConnection(java.sql.Connection applicationConnection)

getApplicationConnection

public final java.sql.Connection getApplicationConnection()

setDrdaID

public void setDrdaID(java.lang.String drdaID)

resetFromPool

public void resetFromPool()
                   throws java.sql.SQLException
Reset 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.


xa_prepare

public final int xa_prepare()
                     throws java.sql.SQLException

xa_commit

public final void xa_commit(boolean onePhase)
                     throws java.sql.SQLException

xa_rollback

public final void xa_rollback()
                       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


setResultSetType

private int setResultSetType(int resultSetType)

setResultSetConcurrency

private int setResultSetConcurrency(int resultSetType,
                                    int resultSetConcurrency)

setPrepareIsolation

public void setPrepareIsolation(int level)
                         throws java.sql.SQLException
Set the transaction isolation level that will be used for the next prepare. Used by network server to implement DB2 style isolation levels.


getPrepareIsolation

public int getPrepareIsolation()
Return prepare isolation


getResultSetOrderId

final int getResultSetOrderId()
Return a unique order number for a result set. A unique value is only needed if the result set is being created within procedure and thus must be using a nested connection.


newSQLException

protected java.sql.SQLException newSQLException(java.lang.String messageId)

newSQLException

protected java.sql.SQLException newSQLException(java.lang.String messageId,
                                                java.lang.Object arg1)

newSQLException

protected java.sql.SQLException newSQLException(java.lang.String messageId,
                                                java.lang.Object arg1,
                                                java.lang.Object arg2)

toString

public java.lang.String toString()
Get a String representation that uniquely identifies this connection 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.