org.apache.derby.client.net
Class NetConnection40

java.lang.Object
  extended by org.apache.derby.client.am.Connection
      extended by org.apache.derby.client.net.NetConnection
          extended by org.apache.derby.client.net.NetConnection40
All Implemented Interfaces:
java.sql.Connection, java.sql.Wrapper, ConnectionCallbackInterface

public class NetConnection40
extends NetConnection


Field Summary
private  java.sql.PreparedStatement isValidStmt
          Prepared statement that is used each time isValid() is called on this connection.
 
Fields inherited from class org.apache.derby.client.net.NetConnection
cnntkn_, crrtkn_, currXACallInfoOffset_, extnam_, indoubtTransactions_, msgutil, netAgent_, pendingEndXACallinfoOffset_, prddta_, publicKey_, readOnlyTransaction_, securityMechanism_, sourceSeed_, targetAgent_, targetCmnappc_, targetCmntcpip_, targetExtnam_, targetPublicKey_, targetRdb_, targetRsyncmgr_, targetSecmec_, targetSecmgr_, targetSeed_, targetSrvclsnm_, targetSrvnam_, targetSrvrlslv_, targetSyncptmgr_, targetXamgr_, xares_
 
Fields inherited from class org.apache.derby.client.am.Connection
agent_, autoCommit_, clientSSLMode_, commBufferSize_, databaseMetaData_, databaseName_, dataSource_, dncGeneratedSavepointId_, dncGeneratedSavepointNamePrefix__, encryptionManager_, inUnitOfWork_, isXAConnection_, jdbcReadOnly_, loginTimeout_, open_, portNumber_, productID_, resetConnectionAtFirstSql_, retrieveMessageText_, serverNameIP_, user_, XA_T0_NOT_ASSOCIATED, XA_T1_ASSOCIATED, xaHostVersion_
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
NetConnection40(NetLogWriter netLogWriter, ClientBaseDataSource dataSource, java.lang.String user, java.lang.String password)
           
NetConnection40(NetLogWriter netLogWriter, int driverManagerLoginTimeout, java.lang.String serverName, int portNumber, java.lang.String databaseName, java.util.Properties properties)
           
NetConnection40(NetLogWriter netLogWriter, java.lang.String ipaddr, int portNumber, ClientBaseDataSource dataSource, boolean isXAConn)
           
NetConnection40(NetLogWriter netLogWriter, java.lang.String databaseName, java.util.Properties properties)
           
NetConnection40(NetLogWriter netLogWriter, java.lang.String user, java.lang.String password, ClientBaseDataSource dataSource, int rmId, boolean isXAConn)
           
NetConnection40(NetLogWriter netLogWriter, java.lang.String user, java.lang.String password, ClientBaseDataSource dataSource, int rmId, boolean isXAConn, ClientPooledConnection cpc)
          The constructor for the NetConnection40 class which contains implementations of JDBC 4.0 specific methods in the java.sql.Connection interface.
 
Method Summary
 void close()
          Close the connection and release its resources.
 java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements)
           
 java.sql.NClob createNClob()
           
 java.sql.SQLXML createSQLXML()
           
 java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes)
           
 java.util.Properties getClientInfo()
          getClientInfo always returns an empty Properties object since Derby doesn't support ClientInfoProperties.
 java.lang.String getClientInfo(java.lang.String name)
          getClientInfo always returns a null String since Derby doesn't support ClientInfoProperties.
 java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
          Returns the type map for this connection.
 boolean isValid(int timeout)
          Checks if the connection has not been closed and is still valid.
 boolean isWrapperFor(java.lang.Class<?> interfaces)
          Returns false unless interfaces is implemented
 void setClientInfo(java.util.Properties properties)
          setClientInfo will throw a SQLClientInfoException uless the properties paramenter is empty, since Derby does not support any properties.
 void setClientInfo(java.lang.String name, java.lang.String value)
          setClientInfo will always throw a SQLClientInfoException since Derby does not support any properties.
<T> T
unwrap(java.lang.Class<T> interfaces)
          Returns this if this class implements the interface
 
Methods inherited from class org.apache.derby.client.net.NetConnection
addSpecialRegisters, allowCloseInUOW_, allowLocalCommitRollback_, checkAlternateServerHasEqualOrHigherProductLevel, closeForReuse, closeResources, closeX, completeConnect, completeReset, constructCrrtkn, doCloseStatementsOnClose_, doResetNow, finalize, flowConnect, flowReconnect, flowSimpleConnect, getAGENT, getCMNTCPIP, getCnnToken, getEncryptionManager, getInputStream, getOutputStream, getProductID, getRDB, getRSYNCMGR, getSECMGR, getSecurityMechanism, getSequenceNumber, getSocketAndInputOutputStreams, getSpecialRegisters, getSQLAM, getSYNCPTMGR, getTargetPublicKey, getXAMGR, isConnectionNull, isGlobalPending_, isOpen, markClosed_, newAgent_, newCallableStatement_, newDatabaseMetaData_, newPositionedUpdatePreparedStatement_, newPreparedStatement_, newSectionManager, newStatement_, rdbAccessed, readCommitSubstitute_, readDeferredReset, readLocalCommit_, readLocalRollback_, readLocalXACommit_, readLocalXARollback_, readLocalXAStart_, readTransactionStart, readXACommit_, readXARollback_, reset_, resetCallableStatement_, resetNetConnection, resetPreparedStatement_, resetStatement_, securityCheckComplete, serverSupportsEXTDTAAbort, serverSupportsLayerBStreaming, serverSupportsLocators, serverSupportsQryclsimp, serverSupportsTimestampNanoseconds, serverSupportsUDTs, setAccessSecurityData, setConnectionNull, setIndoubtTransactions, setInputStream, setOutputStream, setReadOnlyTransactionFlag, setServerAttributeData, supportsSessionDataCaching, willAutoCommitGenerateFlow, writeCommitSubstitute_, writeDeferredReset, writeLocalCommit_, writeLocalRollback_, writeLocalXACommit_, writeLocalXARollback_, writeLocalXAStart_, writeTransactionStart, writeXACommit_, writeXARollback_, writeXATransactionStart
 
Methods inherited from class org.apache.derby.client.am.Connection
accumulate440WarningForMessageProcFailure, accumulate444WarningForMessageProcFailure, accumulateWarning, checkForClosedConnection, clearWarnings, clearWarningsX, closeForReuse, commit, completeAbnormalUnitOfWork, completeAbnormalUnitOfWork, completeChainBreakingDisconnect, completeLocalCommit, completeLocalRollback, completePiggyBackIsolation, completePiggyBackSchema, completeReset, completeSpecificRollback, completeSqlca, createBlob, createClob, createStatement, createStatement, createStatement, flowAutoCommit, flowCommit, flowRollback, getAutoCommit, getCatalog, getCurrentSchemaName, getHoldability, getMetaData, getServerVersion, getTransactionID, getTransactionIsolation, getWarnings, getXAState, initConnection, isClosed, isClosedX, isPhysicalConnClosed, isReadOnly, isXAConnection, lightReset, markClosed, nativeSQL, nativeSQLX, prepareCall, prepareCall, prepareCall, prepareMessageProc, preparePositionedUpdateStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, readCommit, readRollback, releaseSavepoint, reset, resetConnection, resetPrepareCall, resetPrepareStatement, resetStatement, rollback, rollback, setAutoCommit, setCatalog, setHoldability, setInUnitOfWork, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap, setXAState, transactionInProgress, writeCommit, writeRollback
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isValidStmt

private java.sql.PreparedStatement isValidStmt
Prepared statement that is used each time isValid() is called on this connection. The statement is created the first time isValid is called and closed when the connection is closed (by the close call).

Constructor Detail

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       java.lang.String databaseName,
                       java.util.Properties properties)
                throws SqlException
Throws:
SqlException

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       ClientBaseDataSource dataSource,
                       java.lang.String user,
                       java.lang.String password)
                throws SqlException
Throws:
SqlException

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       int driverManagerLoginTimeout,
                       java.lang.String serverName,
                       int portNumber,
                       java.lang.String databaseName,
                       java.util.Properties properties)
                throws SqlException
Throws:
SqlException

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       java.lang.String user,
                       java.lang.String password,
                       ClientBaseDataSource dataSource,
                       int rmId,
                       boolean isXAConn)
                throws SqlException
Throws:
SqlException

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       java.lang.String ipaddr,
                       int portNumber,
                       ClientBaseDataSource dataSource,
                       boolean isXAConn)
                throws SqlException
Throws:
SqlException

NetConnection40

public NetConnection40(NetLogWriter netLogWriter,
                       java.lang.String user,
                       java.lang.String password,
                       ClientBaseDataSource dataSource,
                       int rmId,
                       boolean isXAConn,
                       ClientPooledConnection cpc)
                throws SqlException
The constructor for the NetConnection40 class which contains implementations of JDBC 4.0 specific methods in the java.sql.Connection interface. This constructor is called from the ClientPooledConnection object to enable the NetConnection to pass this on to the associated prepared statement object thus enabling the prepared statement object to inturn raise the statement events to the ClientPooledConnection object.

Parameters:
netLogWriter - NetLogWriter object associated with this connection.
user - user id for this connection.
password - password for this connection.
dataSource - The DataSource object passed from the PooledConnection object from which this constructor was called.
rmId - The Resource manager ID for XA Connections
isXAConn - true if this is a XA connection.
cpc - The ClientPooledConnection object from which this NetConnection constructor was called. This is used to pass StatementEvents back to the pooledConnection object.
Throws:
SqlException
Method Detail

createArrayOf

public java.sql.Array createArrayOf(java.lang.String typeName,
                                    java.lang.Object[] elements)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

createNClob

public java.sql.NClob createNClob()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

createSQLXML

public java.sql.SQLXML createSQLXML()
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

createStruct

public java.sql.Struct createStruct(java.lang.String typeName,
                                    java.lang.Object[] attributes)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

isValid

public boolean isValid(int timeout)
                throws java.sql.SQLException
Checks if the connection has not been closed and is still valid. The validity is checked by running a simple query against the database. The timeout specified by the caller is implemented as follows: On the server: uses the queryTimeout functionality to make the query time out on the server in case the server has problems or is highly loaded. On the client: uses a timeout on the socket to make sure that the client is not blocked forever in the cases where the server is "hanging" or not sending the reply.

Parameters:
timeout - The time in seconds to wait for the database operation used to validate the connection to complete. If the timeout period expires before the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation.
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 occured

close

public void close()
           throws java.sql.SQLException
Close the connection and release its resources.

Specified by:
close in interface java.sql.Connection
Overrides:
close in class NetConnection
Throws:
java.sql.SQLException - if a database-access error occurs.

setClientInfo

public void setClientInfo(java.lang.String name,
                          java.lang.String value)
                   throws java.sql.SQLClientInfoException
setClientInfo will always throw a SQLClientInfoException since Derby does not support any properties.

Parameters:
name - a property key String
value - a property value String
Throws:
java.sql.SQLException - always.
java.sql.SQLClientInfoException

setClientInfo

public void setClientInfo(java.util.Properties properties)
                   throws java.sql.SQLClientInfoException
setClientInfo will throw a SQLClientInfoException uless the properties paramenter is empty, since Derby does not support any properties. All the property keys in the properties parameter are added to failedProperties of the exception thrown, with REASON_UNKNOWN_PROPERTY as the value.

Parameters:
properties - a Properties object with the properties to set.
Throws:
java.sql.SQLClientInfoException - unless the properties parameter is null or empty.

getClientInfo

public java.lang.String getClientInfo(java.lang.String name)
                               throws java.sql.SQLException
getClientInfo always returns a null String since Derby doesn't support ClientInfoProperties.

Parameters:
name - a String value
Returns:
a null String value
Throws:
java.sql.SQLException - if the connection is closed.

getClientInfo

public java.util.Properties getClientInfo()
                                   throws java.sql.SQLException
getClientInfo always returns an empty Properties object since Derby doesn't support ClientInfoProperties.

Returns:
an empty Properties object.
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.SQLException
Returns the type map for this connection.

Specified by:
getTypeMap in interface java.sql.Connection
Overrides:
getTypeMap in class 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.SQLException
Returns false unless interfaces is implemented

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.SQLException
Returns this if this class implements the interface

Parameters:
interfaces - a Class defining an interface
Returns:
an object that implements the interface
Throws:
java.sql.SQLException - if no object if found that implements the interface

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.