Top Fields Constructors Methods
org.apache.derby.impl.jdbc

pack-priv Class EmbedConnectionContext

extends ContextImpl
implements ConnectionContext
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.jdbc.ConnectionContext
Imports
org.apache.derby.iapi.services.context.ContextImpl, .ContextManager, org.apache.derby.iapi.sql.conn.StatementContext, .LanguageConnectionContext, org.apache.derby.iapi.jdbc.ConnectionContext, org.apache.derby.shared.common.error.StandardException, .ExceptionSeverity, org.apache.derby.iapi.sql.ResultSet, java.sql.SQLException, java.util.Vector, .Enumeration

Field Summary

Modifier and TypeField and Description
private SoftReference<EmbedConnection>
connRef

We hold a soft reference to the connection so that when the application releases its reference to the Connection without closing it, its finalize method will be called, which will then close the connection.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
cleanupOnError(Throwable
The original error
error
)

Implements org.apache.derby.iapi.services.context.Context.cleanupOnError.

Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action.

public Connection
getNestedConnection(boolean
True if the connection should be internal
internal
)

Implements org.apache.derby.iapi.jdbc.ConnectionContext.getNestedConnection.

Get a connection equivalent to the call

DriverManager.getConnection("jdbc:default:connection");
public ResultSet
getResultSet(ResultSet
a result set as gotten from execution
executionResultSet
)

Implements org.apache.derby.iapi.jdbc.ConnectionContext.getResultSet.

Get a jdbc ResultSet based on the execution ResultSet.

private LanguageConnectionContext
privilegedGetLCC(final EmbedConnection conn)

Private lookup of the lcc..

public boolean
processInaccessibleDynamicResult(ResultSet
ResultSet to process.
resultSet
)

Implements org.apache.derby.iapi.jdbc.ConnectionContext.processInaccessibleDynamicResult.

Process a ResultSet from a procedure to be a dynamic result, but one that will be closed due to it being inaccessible.

Inherited from org.apache.derby.iapi.services.context.ContextImpl:
appendErrorInfogetContextManagergetIdNameisLastHandlerpopMepushMe

Field Detail

connRefback to summary
private SoftReference<EmbedConnection> connRef

We hold a soft reference to the connection so that when the application releases its reference to the Connection without closing it, its finalize method will be called, which will then close the connection. If a direct reference is used here, such a Connection will never be closed or garbage collected as modules hold onto the ContextManager and thus there would be a direct reference through this object.

Constructor Detail

EmbedConnectionContextback to summary
pack-priv EmbedConnectionContext(ContextManager cm, EmbedConnection conn)

Method Detail

cleanupOnErrorback to summary
public void cleanupOnError(Throwable error)

Implements org.apache.derby.iapi.services.context.Context.cleanupOnError.

Doc from org.apache.derby.iapi.services.context.Context.cleanupOnError.

Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action. They will be told what the error is, so that they can react appropriately. Most of the time, the contexts will react by either doing nothing or by removing themselves from the context manager. If there are no other references to the context, removing itself from the manager equates to freeing it.
On an exception that is session severity or greater the Context must push itself off the stack. This is to ensure that after a session has been closed there are no Contexts on the stack that potentially hold references to objects, thus delaying their garbage collection.

Contexts must release all their resources before removing themselves from their context manager.

The context manager will "unwind" the contexts during cleanup in the reverse order they were placed on its global stack.

If error is an instance of StandardException then an implementation of this method may throw a new exception if and only if the new exception is an instance of StandardException that is more severe than the original error or the new exception is a not an instance of StandardException (e.g java.lang.NullPointerException).

Parameters
error:Throwable

The original error

getNestedConnectionback to summary
public Connection getNestedConnection(boolean internal) throws SQLException

Implements org.apache.derby.iapi.jdbc.ConnectionContext.getNestedConnection.

Get a connection equivalent to the call

DriverManager.getConnection("jdbc:default:connection");
Parameters
internal:boolean

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.getNestedConnection.

True if the connection should be internal

Returns:Connection

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.getNestedConnection.

a nested connection

Exceptions
SQLException:

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.getNestedConnection.

Parent connection has been closed.

getResultSetback to summary
public ResultSet getResultSet(ResultSet executionResultSet) throws SQLException

Implements org.apache.derby.iapi.jdbc.ConnectionContext.getResultSet.

Get a jdbc ResultSet based on the execution ResultSet.

Parameters
executionResultSet:ResultSet

a result set as gotten from execution

Returns:ResultSet

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.getResultSet.

a JDBC ResultSet

Exceptions
SQLException:

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.getResultSet.

on error

privilegedGetLCCback to summary
private LanguageConnectionContext privilegedGetLCC(final EmbedConnection conn)

Private lookup of the lcc..

processInaccessibleDynamicResultback to summary
public boolean processInaccessibleDynamicResult(ResultSet resultSet)

Implements org.apache.derby.iapi.jdbc.ConnectionContext.processInaccessibleDynamicResult.

Process a ResultSet from a procedure to be a dynamic result, but one that will be closed due to it being inaccessible. We cannot simply close the ResultSet as it the nested connection that created it might be closed, leading to its close method being a no-op. This performs all the conversion (linking the ResultSet to a valid connection) required but does not close the ResultSet.

Parameters
resultSet:ResultSet

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.processInaccessibleDynamicResult.

ResultSet to process.

Returns:boolean

Doc from org.apache.derby.iapi.jdbc.ConnectionContext.processInaccessibleDynamicResult.

True if this ResultSet was created by this connection and the result set is open. False otherwise.

See Also
EmbedStatement#processDynamicResult(EmbedConnection, java.sql.ResultSet, EmbedStatement)