Class AbstractFbWireDatabase

    • Constructor Detail

      • AbstractFbWireDatabase

        protected AbstractFbWireDatabase​(WireDatabaseConnection connection,
                                         ProtocolDescriptor descriptor)
        Creates an AbstractFbWireDatabase instance.
        Parameters:
        connection - A WireConnection with an established connection to the server.
        descriptor - The ProtocolDescriptor that created this connection (this is used for creating further dependent objects).
    • Method Detail

      • getXdrIn

        protected final XdrInputStream getXdrIn()
                                         throws java.sql.SQLException
        Gets the XdrInputStream.
        Returns:
        Instance of XdrInputStream
        Throws:
        java.sql.SQLException - If no connection is opened or when exceptions occur retrieving the InputStream
      • getXdrOut

        protected final XdrOutputStream getXdrOut()
                                           throws java.sql.SQLException
        Gets the XdrOutputStream.
        Returns:
        Instance of XdrOutputStream
        Throws:
        java.sql.SQLException - If no connection is opened or when exceptions occur retrieving the OutputStream
      • checkConnected

        protected final void checkConnected()
                                     throws java.sql.SQLException
        Checks if a physical connection to the server is established.
        Specified by:
        checkConnected in class AbstractFbAttachment<WireDatabaseConnection>
        Throws:
        java.sql.SQLException - If not connected.
      • checkAttached

        protected final void checkAttached()
                                    throws java.sql.SQLException
        Checks if a physical connection to the server is established and if the connection is attached to a database.

        This method calls checkConnected(), so it is not necessary to call both.

        Throws:
        java.sql.SQLException - If the database not connected or attached.
      • closeConnection

        protected final void closeConnection()
                                      throws java.io.IOException
        Closes the WireConnection associated with this connection.
        Throws:
        java.io.IOException - For errors closing the connection.
      • setNetworkTimeout

        public void setNetworkTimeout​(int milliseconds)
                               throws java.sql.SQLException
        Description copied from interface: FbAttachment
        Sets the network timeout for this attachment.
        Specified by:
        setNetworkTimeout in interface FbAttachment
        Parameters:
        milliseconds - Timeout in milliseconds; 0 means no timeout. If the attachment doesn't support milliseconds, it should round up to the nearest second.
        Throws:
        java.sql.SQLException - If this attachment is closed, the value of milliseconds is smaller than 0, or if setting the timeout fails.
        java.sql.SQLFeatureNotSupportedException - If this attachment doesn't support (changing) the network timeout.
      • createBlobForOutput

        public final FbBlob createBlobForOutput​(FbTransaction transaction,
                                                BlobParameterBuffer blobParameterBuffer)
        Description copied from interface: FbDatabase
        Creates a blob for write access to a new blob on the server.

        The blob is initially closed.

        Specified by:
        createBlobForOutput in interface FbDatabase
        Parameters:
        transaction - Transaction associated with the blob.
        blobParameterBuffer - Blob Parameter Buffer
        Returns:
        Instance of FbBlob
      • createBlobForInput

        public final FbBlob createBlobForInput​(FbTransaction transaction,
                                               BlobParameterBuffer blobParameterBuffer,
                                               long blobId)
        Description copied from interface: FbDatabase
        Creates a blob for read access to an existing blob on the server.

        The blob is initially closed.

        Specified by:
        createBlobForInput in interface FbDatabase
        Parameters:
        transaction - Transaction associated with the blob.
        blobParameterBuffer - Blob Parameter Buffer
        blobId - Handle id of the blob
        Returns:
        Instance of FbBlob
      • consumePackets

        public final void consumePackets​(int numberOfResponses,
                                         WarningMessageCallback warningCallback)
        Description copied from interface: FbWireDatabase
        Consumes packets notifying for warnings, but ignoring exceptions thrown from the packet.

        This method should only be used inside the implementation if either packets need to be ignored, or to ensure that there is no backlog of packets (eg when an exception occurs during processing of multiple package responses).

        Specified by:
        consumePackets in interface FbWireDatabase
        Parameters:
        numberOfResponses - Number of responses to consume.
        warningCallback - Callback for warnings
      • readGenericResponse

        public final GenericResponse readGenericResponse​(WarningMessageCallback warningCallback)
                                                  throws java.sql.SQLException,
                                                         java.io.IOException
        Description copied from interface: FbWireAttachment
        Convenience method to read a Response to a GenericResponse
        Specified by:
        readGenericResponse in interface FbWireAttachment
        Parameters:
        warningCallback - Callback object for warnings, null for default callback
        Returns:
        GenericResponse
        Throws:
        java.sql.SQLException - For errors returned from the server, or when attempting to read.
        java.io.IOException - For errors reading the response from the connection.
      • readSqlResponse

        public final SqlResponse readSqlResponse​(WarningMessageCallback warningCallback)
                                          throws java.sql.SQLException,
                                                 java.io.IOException
        Description copied from interface: FbWireDatabase
        Convenience method to read a Response to a SqlResponse
        Specified by:
        readSqlResponse in interface FbWireDatabase
        Parameters:
        warningCallback - Callback object for warnings, null for default callback
        Returns:
        SqlResponse
        Throws:
        java.sql.SQLException - For errors returned from the server, or when attempting to read.
        java.io.IOException - For errors reading the response from the connection.
      • readResponse

        public final Response readResponse​(WarningMessageCallback warningCallback)
                                    throws java.sql.SQLException,
                                           java.io.IOException
        Description copied from interface: FbWireDatabase
        Reads the response from the server.
        Specified by:
        readResponse in interface FbWireDatabase
        Parameters:
        warningCallback - Callback object for warnings, null for default callback
        Returns:
        Response read.
        Throws:
        java.sql.SQLException - For errors returned from the server, or when attempting to read
        java.io.IOException - For errors reading the response from the connection.
      • queueEvent

        public final void queueEvent​(EventHandle eventHandle)
                              throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Queues a wait for an event.
        Specified by:
        queueEvent in interface FbDatabase
        Parameters:
        eventHandle - The event handle (created using FbDatabase.createEventHandle(String, EventHandler) of this instance).
        Throws:
        java.sql.SQLException - For errors establishing the asynchronous channel, or for queuing the event.
      • cancelEvent

        public final void cancelEvent​(EventHandle eventHandle)
                               throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Cancels a registered event.

        After cancellation, the event handle should be considered unusable. Before queueing a new event, an new handle needs to be created.

        Specified by:
        cancelEvent in interface FbDatabase
        Parameters:
        eventHandle - The event handle to cancel
        Throws:
        java.sql.SQLException - For errors cancelling the event
      • countEvents

        public final void countEvents​(EventHandle eventHandle)
                               throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Counts the events occurred.
        Specified by:
        countEvents in interface FbDatabase
        Parameters:
        eventHandle - The event handle
        Throws:
        java.sql.SQLException - When the count can not be done (as - for example - the event handle is of the wrong type)
      • initAsynchronousChannel

        public abstract FbWireAsynchronousChannel initAsynchronousChannel()
                                                                   throws java.sql.SQLException
        Initializes the asynchronous channel (for event notification).
        Throws:
        java.sql.SQLException - For errors establishing the channel, or if the channel already exists.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable