Class WireConnection<T extends IAttachProperties<T>,​C extends FbWireAttachment>

    • Constructor Detail

      • WireConnection

        protected WireConnection​(T attachProperties)
                          throws java.sql.SQLException
        Creates a WireConnection (without establishing a connection to the server) with the default protocol collection.
        Parameters:
        attachProperties - Attach properties
        Throws:
        java.sql.SQLException
      • WireConnection

        protected WireConnection​(T attachProperties,
                                 IEncodingFactory encodingFactory,
                                 ProtocolCollection protocols)
                          throws java.sql.SQLException
        Creates a WireConnection (without establishing a connection to the server).
        Parameters:
        attachProperties - Attach properties
        encodingFactory - Factory for encoding definitions
        protocols - The collection of protocols to use for this connection.
        Throws:
        java.sql.SQLException
    • Method Detail

      • getServerName

        public final java.lang.String getServerName()
      • getPortNumber

        public final int getPortNumber()
      • getCnctFile

        protected java.lang.String getCnctFile()
        Returns:
        The file name to use in the p_cnct_file of the op_connect request
      • getAttachObjectName

        public final java.lang.String getAttachObjectName()
      • toDbAttachInfo

        protected abstract DbAttachInfo toDbAttachInfo​(T attachProperties)
                                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isConnected

        public final boolean isConnected()
      • getProtocolVersion

        public final int getProtocolVersion()
      • getProtocolArchitecture

        public final int getProtocolArchitecture()
      • getProtocolMinimumType

        public final int getProtocolMinimumType()
      • setSoTimeout

        public final void setSoTimeout​(int socketTimeout)
                                throws java.sql.SQLException
        Sets the socket blocking timeout (SO_TIMEOUT) of the socket.

        This method can also be called if a connection is established

        Parameters:
        socketTimeout - Value of the socket timeout (in milliseconds)
        Throws:
        java.sql.SQLException - If the timeout value cannot be changed
      • resetSocketTimeout

        public final void resetSocketTimeout()
                                      throws java.sql.SQLException
        Resets the socket timeout to the configured socketTimeout. Does nothing if currently not connected.
        Throws:
        java.sql.SQLException - If the timeout value cannot be changed
      • socketConnect

        public final void socketConnect()
                                 throws java.sql.SQLException
        Establishes the TCP/IP connection to serverName and portNumber of this Connection
        Throws:
        java.sql.SQLTimeoutException - If the connection cannot be established within the connect timeout (either explicitly set or implied by the OS timeout of the socket)
        java.sql.SQLException - If the connection cannot be established.
      • identify

        public final C identify()
                         throws java.sql.SQLException
        Performs the connection identification phase of the Wire protocol and returns the FbWireDatabase implementation for the agreed protocol.
        Specified by:
        identify in class AbstractConnection<T extends IAttachProperties<T>,​C extends FbWireAttachment>
        Returns:
        FbWireDatabase
        Throws:
        java.sql.SQLException - For exceptions connecting
      • clearAuthData

        public final void clearAuthData()
        Clear authentication data.
      • createConnectionHandle

        protected abstract C createConnectionHandle​(ProtocolDescriptor protocolDescriptor)
        Creates the connection handle for this type of connection.
        Parameters:
        protocolDescriptor - The protocol descriptor selected by the identify phase
        Returns:
        Connection handle
      • readNextOperation

        public final int readNextOperation()
                                    throws java.io.IOException
        Reads the next operation code. Skips all WireProtocolConstants.op_dummy codes received.
        Returns:
        Operation code
        Throws:
        java.io.IOException - if an error occurs while reading from the underlying InputStream
      • close

        public final void close()
                         throws java.io.IOException
        Closes the TCP/IP connection. This is not a normal detach operation.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException - if closing fails
      • writeDirect

        public final void writeDirect​(byte[] data)
                               throws java.io.IOException
        Writes directly to the OutputStream of the underlying socket.
        Parameters:
        data - Data to write
        Throws:
        java.io.IOException - If there is no socket, the socket is closed, or for errors writing to the socket.