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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.apache.derby.iapi.services.context.ContextImpl
      extended byorg.apache.derby.impl.jdbc.EmbedConnectionContext
All Implemented Interfaces:
org.apache.derby.iapi.jdbc.ConnectionContext, org.apache.derby.iapi.services.context.Context

public class EmbedConnectionContext
extends org.apache.derby.iapi.services.context.ContextImpl
implements org.apache.derby.iapi.jdbc.ConnectionContext


Field Summary
private  java.lang.ref.SoftReference 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.
 
Fields inherited from class org.apache.derby.iapi.services.context.ContextImpl
 
Fields inherited from interface org.apache.derby.iapi.jdbc.ConnectionContext
CONTEXT_ID
 
Constructor Summary
(package private) EmbedConnectionContext(org.apache.derby.iapi.services.context.ContextManager cm, EmbedConnection conn)
           
 
Method Summary
 void cleanupOnError(java.lang.Throwable error)
          Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action.
 java.sql.Connection getNestedConnection(boolean internal)
          Get a connection equivalent to the call
 java.sql.ResultSet getResultSet(org.apache.derby.iapi.sql.ResultSet executionResultSet)
          Get a jdbc ResultSet based on the execution ResultSet.
 
Methods inherited from class org.apache.derby.iapi.services.context.ContextImpl
appendErrorInfo, getContextManager, getIdName, isLastHandler, popMe, pushMe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connRef

private java.lang.ref.SoftReference 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

EmbedConnectionContext

EmbedConnectionContext(org.apache.derby.iapi.services.context.ContextManager cm,
                       EmbedConnection conn)
Method Detail

cleanupOnError

public void cleanupOnError(java.lang.Throwable error)
Description copied from interface: org.apache.derby.iapi.services.context.Context
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.

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

Specified by:
cleanupOnError in interface org.apache.derby.iapi.services.context.Context

getNestedConnection

public java.sql.Connection getNestedConnection(boolean internal)
                                        throws java.sql.SQLException
Get a connection equivalent to the call
                DriverManager.getConnection("jdbc:default:connection");
                

Specified by:
getNestedConnection in interface org.apache.derby.iapi.jdbc.ConnectionContext

getResultSet

public java.sql.ResultSet getResultSet(org.apache.derby.iapi.sql.ResultSet executionResultSet)
                                throws java.sql.SQLException
Get a jdbc ResultSet based on the execution ResultSet.

Specified by:
getResultSet in interface org.apache.derby.iapi.jdbc.ConnectionContext