org.apache.derby.iapi.jdbc
Class BrokeredConnection

java.lang.Object
  extended by org.apache.derby.iapi.jdbc.BrokeredConnection
All Implemented Interfaces:
java.sql.Connection, java.sql.Wrapper, EngineConnection
Direct Known Subclasses:
BrokeredConnection30

public abstract class BrokeredConnection
extends java.lang.Object
implements EngineConnection

This is a rudimentary connection that delegates EVERYTHING to Connection.


Field Summary
private  java.lang.String connString
           
(package private)  BrokeredConnectionControl control
           
private  boolean isClosed
           
private  boolean stateAutoCommit
           
(package private)  int stateHoldability
           
private  int stateIsolationLevel
          Maintain state as seen by this Connection handle, not the state of the underlying Connection it is attached to.
private  boolean stateReadOnly
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
BrokeredConnection(BrokeredConnectionControl control)
           
 
Method Summary
 void addWarning(java.sql.SQLWarning w)
          Add a SQLWarning to this Connection object.
protected  void checkIfClosed()
          Checks if the connection is closed and throws an exception if it is.
 void clearLOBMapping()
          Clear the HashMap of all entries.
 void clearWarnings()
           
 void close()
           
 void commit()
           
 java.sql.Statement createStatement()
           
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
           
 boolean getAutoCommit()
           
 java.lang.String getCatalog()
           
 java.lang.String getCurrentSchemaName()
          Obtain the name of the current schema.
 int getHoldability()
          Get the holdability for statements created by this connection when holdability is not passed in.
 void getIsolationUptoDate()
          Isolation level state in BrokeredConnection can get out of sync if the isolation is set using SQL rather than JDBC.
 java.lang.Object getLOBMapping(int key)
          Get the LOB reference corresponding to the locator.
 java.sql.DatabaseMetaData getMetaData()
           
 int getPrepareIsolation()
          get the isolation level that is currently being used to prepare statements (used for network server)
(package private)  EngineConnection getRealConnection()
          A little indirection for getting the real connection.
 int getTransactionIsolation()
           
 java.util.Map getTypeMap()
           
 java.sql.SQLWarning getWarnings()
           
 boolean isClosed()
           
 boolean isInGlobalTransaction()
          Is this a global transaction
 boolean isReadOnly()
           
 java.lang.String nativeSQL(java.lang.String sql)
           
 BrokeredStatement newBrokeredStatement(BrokeredStatementControl statementControl)
           
abstract  BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl, java.lang.String sql)
           
abstract  BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, java.lang.String sql, java.lang.Object generatedKeys)
           
(package private)  void notifyException(java.sql.SQLException sqle)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Prepare statement with explicit holdability.
 void resetFromPool()
          Resets the connection before it is returned from a PooledConnection to a new application request (wrapped by a BrokeredConnection).
 void rollback()
           
 void setAutoCommit(boolean autoCommit)
           
 void setCatalog(java.lang.String catalog)
           
 void setDrdaID(java.lang.String drdaID)
          set the DrdaId for this connection.
 void setPrepareIsolation(int level)
          Set the internal isolation level to use for preparing statements.
 void setReadOnly(boolean readOnly)
           
 void setState(boolean complete)
          Set the state of the underlying connection according to the state of this connection's view of state.
 void setTransactionIsolation(int level)
           
 void setTypeMap(java.util.Map map)
           
(package private)  int statementHoldabilityCheck(int resultSetHoldability)
          Check the result set holdability when creating a statement object.
 void syncState()
          Sync up the state of the underlying connection with the state of this new handle.
 java.lang.String toString()
          Get the string representation for this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStruct, getClientInfo, getClientInfo, isValid, prepareCall, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setClientInfo, setClientInfo, setHoldability, setSavepoint, setSavepoint
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Field Detail

stateHoldability

int stateHoldability

control

final BrokeredConnectionControl control

isClosed

private boolean isClosed

connString

private java.lang.String connString

stateIsolationLevel

private int stateIsolationLevel
Maintain state as seen by this Connection handle, not the state of the underlying Connection it is attached to.


stateReadOnly

private boolean stateReadOnly

stateAutoCommit

private boolean stateAutoCommit
Constructor Detail

BrokeredConnection

public BrokeredConnection(BrokeredConnectionControl control)
Method Detail

setAutoCommit

public final void setAutoCommit(boolean autoCommit)
                         throws java.sql.SQLException
Specified by:
setAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException

getAutoCommit

public final boolean getAutoCommit()
                            throws java.sql.SQLException
Specified by:
getAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException

createStatement

public final java.sql.Statement createStatement()
                                         throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                                  throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql)
                                             throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException

nativeSQL

public final java.lang.String nativeSQL(java.lang.String sql)
                                 throws java.sql.SQLException
Specified by:
nativeSQL in interface java.sql.Connection
Throws:
java.sql.SQLException

commit

public final void commit()
                  throws java.sql.SQLException
Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException

rollback

public final void rollback()
                    throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException

close

public final void close()
                 throws java.sql.SQLException
Specified by:
close in interface java.sql.Connection
Throws:
java.sql.SQLException

isClosed

public final boolean isClosed()
                       throws java.sql.SQLException
Specified by:
isClosed in interface java.sql.Connection
Throws:
java.sql.SQLException

getWarnings

public final java.sql.SQLWarning getWarnings()
                                      throws java.sql.SQLException
Specified by:
getWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException

clearWarnings

public final void clearWarnings()
                         throws java.sql.SQLException
Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException

getMetaData

public final java.sql.DatabaseMetaData getMetaData()
                                            throws java.sql.SQLException
Specified by:
getMetaData in interface java.sql.Connection
Throws:
java.sql.SQLException

setReadOnly

public final void setReadOnly(boolean readOnly)
                       throws java.sql.SQLException
Specified by:
setReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException

isReadOnly

public final boolean isReadOnly()
                         throws java.sql.SQLException
Specified by:
isReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException

setCatalog

public final void setCatalog(java.lang.String catalog)
                      throws java.sql.SQLException
Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException

getCatalog

public final java.lang.String getCatalog()
                                  throws java.sql.SQLException
Specified by:
getCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException

setTransactionIsolation

public final void setTransactionIsolation(int level)
                                   throws java.sql.SQLException
Specified by:
setTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException

getTransactionIsolation

public final int getTransactionIsolation()
                                  throws java.sql.SQLException
Specified by:
getTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException

createStatement

public final java.sql.Statement createStatement(int resultSetType,
                                                int resultSetConcurrency)
                                         throws java.sql.SQLException
Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int resultSetType,
                                                         int resultSetConcurrency)
                                                  throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareCall

public final java.sql.CallableStatement prepareCall(java.lang.String sql,
                                                    int resultSetType,
                                                    int resultSetConcurrency)
                                             throws java.sql.SQLException
Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException

setTypeMap

public final void setTypeMap(java.util.Map map)
                      throws java.sql.SQLException
Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException

getRealConnection

final EngineConnection getRealConnection()
                                  throws java.sql.SQLException
A little indirection for getting the real connection.

Returns:
the current connection
Throws:
java.sql.SQLException

notifyException

final void notifyException(java.sql.SQLException sqle)

syncState

public void syncState()
               throws java.sql.SQLException
Sync up the state of the underlying connection with the state of this new handle.

Throws:
java.sql.SQLException

getIsolationUptoDate

public void getIsolationUptoDate()
                          throws java.sql.SQLException
Isolation level state in BrokeredConnection can get out of sync if the isolation is set using SQL rather than JDBC. In order to ensure correct state level information, this method is called at the start and end of a global transaction.

Throws:
java.sql.SQLException

setState

public void setState(boolean complete)
              throws java.sql.SQLException
Set the state of the underlying connection according to the state of this connection's view of state.

Parameters:
complete - If true set the complete state of the underlying Connection, otherwise set only the Connection related state (ie. the non-transaction specific state).
Throws:
java.sql.SQLException

newBrokeredStatement

public BrokeredStatement newBrokeredStatement(BrokeredStatementControl statementControl)
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

newBrokeredStatement

public abstract BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl,
                                                               java.lang.String sql,
                                                               java.lang.Object generatedKeys)
                                                        throws java.sql.SQLException
Throws:
java.sql.SQLException

newBrokeredStatement

public abstract BrokeredCallableStatement newBrokeredStatement(BrokeredStatementControl statementControl,
                                                               java.lang.String sql)
                                                        throws java.sql.SQLException
Throws:
java.sql.SQLException

setDrdaID

public final void setDrdaID(java.lang.String drdaID)
set the DrdaId for this connection. The drdaID prints with the statement text to the errror log

Specified by:
setDrdaID in interface EngineConnection
Parameters:
drdaID - drdaID to be used for this connection

isInGlobalTransaction

public boolean isInGlobalTransaction()
Description copied from interface: EngineConnection
Is this a global transaction

Specified by:
isInGlobalTransaction in interface EngineConnection
Returns:
true if this is a global XA transaction
See Also:
EngineConnection.isInGlobalTransaction()

setPrepareIsolation

public final void setPrepareIsolation(int level)
                               throws java.sql.SQLException
Set the internal isolation level to use for preparing statements. Subsequent prepares will use this isoalation level

Specified by:
setPrepareIsolation in interface EngineConnection
Parameters:
level - - internal isolation level
Throws:
java.sql.SQLException - See EmbedConnection#setPrepareIsolation

getPrepareIsolation

public final int getPrepareIsolation()
                              throws java.sql.SQLException
get the isolation level that is currently being used to prepare statements (used for network server)

Specified by:
getPrepareIsolation in interface EngineConnection
Returns:
current prepare isolation level See EmbedConnection#getPrepareIsolation
Throws:
java.sql.SQLException

addWarning

public final void addWarning(java.sql.SQLWarning w)
                      throws java.sql.SQLException
Add a SQLWarning to this Connection object.

Specified by:
addWarning in interface EngineConnection
Parameters:
w - Warning to be added, will be chained to any existing warnings.
Throws:
java.sql.SQLException

checkIfClosed

protected final void checkIfClosed()
                            throws java.sql.SQLException
Checks if the connection is closed and throws an exception if it is.

Throws:
java.sql.SQLException - if the connection is closed

toString

public java.lang.String toString()
Get the string representation for this connection. Return the class name/hash code and various debug information.

Overrides:
toString in class java.lang.Object
Returns:
unique string representation for this connection

prepareStatement

public final java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                         int resultSetType,
                                                         int resultSetConcurrency,
                                                         int resultSetHoldability)
                                                  throws java.sql.SQLException
Prepare statement with explicit holdability.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

getHoldability

public final int getHoldability()
                         throws java.sql.SQLException
Get the holdability for statements created by this connection when holdability is not passed in.

Specified by:
getHoldability in interface java.sql.Connection
Specified by:
getHoldability in interface EngineConnection
Throws:
java.sql.SQLException

statementHoldabilityCheck

final int statementHoldabilityCheck(int resultSetHoldability)
                             throws java.sql.SQLException
Check the result set holdability when creating a statement object. Section 16.1.3.1 of JDBC 4.0 (proposed final draft) says the driver may change the holdabilty and add a SQLWarning to the Connection object. This work-in-progress implementation throws an exception to match the old behaviour just as part of incremental development.

Throws:
java.sql.SQLException

clearLOBMapping

public void clearLOBMapping()
                     throws java.sql.SQLException
Clear the HashMap of all entries. Called when a commit or rollback of the transaction happens.

Specified by:
clearLOBMapping in interface EngineConnection
Throws:
java.sql.SQLException

getLOBMapping

public java.lang.Object getLOBMapping(int key)
                               throws java.sql.SQLException
Get the LOB reference corresponding to the locator.

Specified by:
getLOBMapping in interface EngineConnection
Parameters:
key - the integer that represents the LOB locator value.
Returns:
the LOB Object corresponding to this locator.
Throws:
java.sql.SQLException

getCurrentSchemaName

public java.lang.String getCurrentSchemaName()
                                      throws java.sql.SQLException
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:
getCurrentSchemaName in interface EngineConnection
Returns:
the current schema name
Throws:
java.sql.SQLException

resetFromPool

public void resetFromPool()
                   throws java.sql.SQLException
Description copied from interface: EngineConnection
Resets the connection before it is returned from a PooledConnection to a new application request (wrapped by a BrokeredConnection).

Note that resetting the transaction isolation level is not performed as part of this method. Temporary tables, IDENTITY_VAL_LOCAL and current schema are reset.

Specified by:
resetFromPool in interface EngineConnection
Throws:
java.sql.SQLException
See Also:
EngineConnection

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.