Class NetConnection

    • Field Detail

      • netAgent_

        protected NetAgent netAgent_
      • closeStatementsOnClose

        private final boolean closeStatementsOnClose
      • targetAgent_

        protected int targetAgent_
      • targetCmntcpip_

        protected int targetCmntcpip_
      • targetRdb_

        protected int targetRdb_
      • targetSecmgr_

        int targetSecmgr_
      • targetCmnappc_

        protected int targetCmnappc_
      • targetXamgr_

        protected int targetXamgr_
      • targetSyncptmgr_

        protected int targetSyncptmgr_
      • targetRsyncmgr_

        protected int targetRsyncmgr_
      • targetUnicodemgr_

        protected int targetUnicodemgr_
      • extnam_

        private java.lang.String extnam_
      • targetSrvclsnm_

        java.lang.String targetSrvclsnm_
      • targetSrvrlslv_

        java.lang.String targetSrvrlslv_
      • publicKey_

        private transient byte[] publicKey_
      • targetPublicKey_

        private transient byte[] targetPublicKey_
      • sourceSeed_

        private transient byte[] sourceSeed_
      • targetSeed_

        private transient byte[] targetSeed_
      • prddta_

        private java.nio.ByteBuffer prddta_
      • crrtkn_

        byte[] crrtkn_
      • targetSecmec_

        private int targetSecmec_
      • securityMechanism_

        private int securityMechanism_
      • deferredResetPassword_

        private transient char[] deferredResetPassword_
      • connectionNull

        private boolean connectionNull
      • indoubtTransactions_

        private java.util.List<javax.transaction.xa.Xid> indoubtTransactions_
      • currXACallInfoOffset_

        protected int currXACallInfoOffset_
      • 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

      • NetConnection

        NetConnection​(LogWriter logWriter,
                      int driverManagerLoginTimeout,
                      java.lang.String serverName,
                      int portNumber,
                      java.lang.String databaseName,
                      java.util.Properties properties)
               throws SqlException
        Throws:
        SqlException
      • NetConnection

        NetConnection​(LogWriter logWriter,
                      java.lang.String user,
                      java.lang.String password,
                      BasicClientDataSource40 dataSource,
                      int rmId,
                      boolean isXAConn,
                      ClientPooledConnection cpc)
               throws SqlException
        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 in turn raise the statement events to the ClientPooledConnection object
        Parameters:
        logWriter - LogWriter 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

      • setDeferredResetPassword

        private void setDeferredResetPassword​(java.lang.String password)
      • getDeferredResetPassword

        private java.lang.String getDeferredResetPassword()
      • flowConnect

        private void flowConnect​(java.lang.String password,
                                 int securityMechanism)
                          throws SqlException
        Throws:
        SqlException
      • handleLoginTimeout

        private void handleLoginTimeout​(java.lang.Throwable original)
                                 throws SqlException
        Handle socket timeouts during connection attempts
        Throws:
        SqlException
      • flowReconnect

        private boolean flowReconnect​(java.lang.String password,
                                      int securityMechanism)
                               throws SqlException
        Throws:
        SqlException
      • flowUSRIDPWDconnect

        private void flowUSRIDPWDconnect​(java.lang.String password)
                                  throws SqlException
        Throws:
        SqlException
      • flowUSRENCPWDconnect

        private void flowUSRENCPWDconnect​(java.lang.String password)
                                   throws SqlException
        Throws:
        SqlException
      • flowEUSRIDPWDconnect

        private void flowEUSRIDPWDconnect​(java.lang.String password)
                                   throws SqlException
        Throws:
        SqlException
      • flowEUSRPWDDTAconnect

        private void flowEUSRPWDDTAconnect​(java.lang.String password)
                                    throws SqlException
        Throws:
        SqlException
      • flowUSRSSBPWDconnect

        private void flowUSRSSBPWDconnect​(java.lang.String password)
                                   throws SqlException
        The User ID and Strong Password Substitute mechanism (USRSSBPWD) authenticates the user like the user ID and password mechanism, but the password does not flow. A password substitute is generated instead using the SHA-1 algorithm, and is sent to the application server. The application server generates a password substitute using the same algorithm and compares it with the application requester's password substitute. If equal, the user is authenticated. The SECTKN parameter is used to flow the client and server encryption seeds on the ACCSEC and ACCSECRD commands. More information in DRDA, V3, Volume 3 standard - PWDSSB (page 650)
        Throws:
        SqlException
      • flowKeyExchange

        private void flowKeyExchange​(int securityMechanism,
                                     byte[] publicKey)
                              throws SqlException
        Throws:
        SqlException
      • flowSeedExchange

        private void flowSeedExchange​(int securityMechanism,
                                      byte[] sourceSeed)
                               throws SqlException
        Throws:
        SqlException
      • flowServerAttributesAndKeyExchange

        private void flowServerAttributesAndKeyExchange​(int securityMechanism,
                                                        byte[] publicKey)
                                                 throws SqlException
        Throws:
        SqlException
      • flowSecurityCheckAndAccessRdb

        private void flowSecurityCheckAndAccessRdb​(int securityMechanism,
                                                   java.lang.String user,
                                                   java.lang.String password,
                                                   byte[] encryptedUserid,
                                                   byte[] encryptedPassword)
                                            throws SqlException
        Throws:
        SqlException
      • writeAllConnectCommandsChained

        private void writeAllConnectCommandsChained​(int securityMechanism,
                                                    java.lang.String user,
                                                    java.lang.String password)
                                             throws SqlException
        Throws:
        SqlException
      • readAllConnectCommandsChained

        private void readAllConnectCommandsChained​(int securityMechanism)
                                            throws SqlException
        Throws:
        SqlException
      • writeServerAttributesAndKeyExchange

        private void writeServerAttributesAndKeyExchange​(int securityMechanism,
                                                         byte[] publicKey)
                                                  throws SqlException
        Throws:
        SqlException
      • readServerAttributesAndKeyExchange

        private void readServerAttributesAndKeyExchange​(int securityMechanism)
                                                 throws SqlException
        Throws:
        SqlException
      • writeSecurityCheckAndAccessRdb

        private void writeSecurityCheckAndAccessRdb​(int securityMechanism,
                                                    java.lang.String user,
                                                    java.lang.String password,
                                                    byte[] encryptedUserid,
                                                    byte[] encryptedPassword)
                                             throws SqlException
        Throws:
        SqlException
      • setServerAttributeData

        void setServerAttributeData​(java.lang.String srvclsnm,
                                    java.lang.String srvrlslv)
      • setAccessSecurityData

        void setAccessSecurityData​(int secchkcd,
                                   int desiredSecmec,
                                   int[] secmecList,
                                   boolean sectknReceived,
                                   byte[] sectkn)
                            throws DisconnectException
        Throws:
        DisconnectException
      • securityCheckComplete

        void securityCheckComplete​(int svrcod,
                                   int secchkcd)
      • rdbAccessed

        void rdbAccessed​(int svrcod,
                         java.lang.String prdid,
                         boolean crrtknReceived,
                         byte[] crrtkn)
      • checkPasswordLength

        private void checkPasswordLength​(java.lang.String password)
                                  throws SqlException
        Throws:
        SqlException
      • checkUserPassword

        private void checkUserPassword​(java.lang.String user,
                                       java.lang.String password)
                                throws SqlException
        Throws:
        SqlException
      • checkSecmgrForSecmecSupport

        private void checkSecmgrForSecmecSupport​(int securityMechanism)
                                          throws SqlException
        Throws:
        SqlException
      • mapSecchkcd

        private SqlException mapSecchkcd​(int secchkcd)
      • initializePublicKeyForEncryption

        private void initializePublicKeyForEncryption()
                                               throws SqlException
        Throws:
        SqlException
      • encryptedPasswordForUSRENCPWD

        private byte[] encryptedPasswordForUSRENCPWD​(java.lang.String password)
                                              throws SqlException
        Throws:
        SqlException
      • encryptedPasswordForEUSRIDPWD

        private byte[] encryptedPasswordForEUSRIDPWD​(java.lang.String password)
                                              throws SqlException
        Throws:
        SqlException
      • passwordSubstituteForUSRSSBPWD

        private byte[] passwordSubstituteForUSRSSBPWD​(java.lang.String password)
                                               throws SqlException
        Throws:
        SqlException
      • getSQLAM

        public int getSQLAM()
      • getAGENT

        public int getAGENT()
      • getCMNTCPIP

        public int getCMNTCPIP()
      • getRDB

        public int getRDB()
      • getSECMGR

        public int getSECMGR()
      • getXAMGR

        public int getXAMGR()
      • getSYNCPTMGR

        public int getSYNCPTMGR()
      • getRSYNCMGR

        public int getRSYNCMGR()
      • flipBits

        private char[] flipBits​(char[] array)
      • allowCloseInUOW_

        protected boolean allowCloseInUOW_()
        Check if the connection can be closed when there are uncommitted operations.
        Specified by:
        allowCloseInUOW_ in class ClientConnection
        Returns:
        if this connection can be closed when it has uncommitted operations, true; otherwise, false
      • setInputStream

        public void setInputStream​(java.io.InputStream inputStream)
      • setOutputStream

        public void setOutputStream​(java.io.OutputStream outputStream)
      • getInputStream

        public java.io.InputStream getInputStream()
      • getOutputStream

        public java.io.OutputStream getOutputStream()
      • setIndoubtTransactions

        public void setIndoubtTransactions​(java.util.List<javax.transaction.xa.Xid> indoubtTransactions)
      • getIndoubtTransactionIds

        javax.transaction.xa.Xid[] getIndoubtTransactionIds()
      • getSecurityMechanism

        public int getSecurityMechanism()
      • getTargetPublicKey

        public byte[] getTargetPublicKey()
      • getProductID

        public java.lang.String getProductID()
      • isConnectionNull

        public final boolean isConnectionNull()
        Returns:
        Returns the connectionNull.
      • setConnectionNull

        public void setConnectionNull​(boolean connectionNull)
        Parameters:
        connectionNull - The connectionNull to set.
      • serverSupportsQryclsimp

        final boolean serverSupportsQryclsimp()
        Check whether the server has full support for the QRYCLSIMP parameter in OPNQRY.
        Returns:
        true if QRYCLSIMP is fully supported
      • serverSupportsLayerBStreaming

        public final boolean serverSupportsLayerBStreaming()
      • serverSupportLongRDBNAM

        public final boolean serverSupportLongRDBNAM()
      • supportsSessionDataCaching

        protected final boolean supportsSessionDataCaching()
        Check whether the server supports session data caching
        Specified by:
        supportsSessionDataCaching in class ClientConnection
        Returns:
        true session data caching is supported
      • serverSupportsUtf8Ccsid

        protected final boolean serverSupportsUtf8Ccsid()
        Check whether the server supports the UTF-8 Ccsid Manager
        Returns:
        true if the server supports the UTF-8 Ccsid Manager
      • serverSupportsUDTs

        protected final boolean serverSupportsUDTs()
        Check whether the server supports UDTs
        Returns:
        true if UDTs are supported
      • serverSupportsEXTDTAAbort

        protected final boolean serverSupportsEXTDTAAbort()
      • serverSupportsLocators

        protected final boolean serverSupportsLocators()
        Checks whether the server supports locators for large objects.
        Specified by:
        serverSupportsLocators in class ClientConnection
        Returns:
        true if LOB locators are supported.
      • isOpen

        public boolean isOpen()
        Returns if a transaction is in process
        Returns:
        open
      • 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 occurred
      • close

        public void close()
                   throws java.sql.SQLException
        Close the connection and release its resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Overrides:
        close in class ClientConnection
        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.SQLClientInfoException - always.
      • setClientInfo

        public void setClientInfo​(java.util.Properties properties)
                           throws java.sql.SQLClientInfoException
        setClientInfo will throw a SQLClientInfoException unless the properties parameter 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.
      • 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