Class V10Database

    • Constructor Detail

      • V10Database

        protected V10Database​(WireDatabaseConnection connection,
                              ProtocolDescriptor descriptor)
        Creates a V10Database 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

      • attach

        public final void attach()
                          throws java.sql.SQLException
        Description copied from interface: FbAttachment
        Attach to the attachment type.
        Specified by:
        attach in interface FbAttachment
        Throws:
        java.sql.SQLException
      • attachOrCreate

        protected final void attachOrCreate​(DatabaseParameterBuffer dpb,
                                            boolean create)
                                     throws java.sql.SQLException
        Parameters:
        dpb - Database parameter buffer
        create - true create database, false only attach
        Throws:
        java.sql.SQLException - For errors during attach or create
      • sendAttachOrCreateToBuffer

        protected final void sendAttachOrCreateToBuffer​(DatabaseParameterBuffer dpb,
                                                        boolean create)
                                                 throws java.sql.SQLException,
                                                        java.io.IOException
        Sends the buffer for op_attach or op_create
        Parameters:
        dpb - Database parameter buffer
        create - true create database, false only attach
        Throws:
        java.sql.SQLException - If the connection is not open
        java.io.IOException - For errors writing to the connection
      • getFilenameEncoding

        protected Encoding getFilenameEncoding​(DatabaseParameterBuffer dpb)
        Gets the Encoding to use for the database filename.
        Parameters:
        dpb - Database parameter buffer
        Returns:
        Encoding
      • processAttachOrCreateResponse

        protected final void processAttachOrCreateResponse​(GenericResponse genericResponse)
        Processes the response from the server to the attach or create operation.
        Parameters:
        genericResponse - GenericResponse received from the server.
      • afterAttachActions

        protected final void afterAttachActions()
                                         throws java.sql.SQLException
        Additional tasks to execute directly after attach operation.

        Implementation retrieves database information like dialect ODS and server version.

        Throws:
        java.sql.SQLException - For errors reading or writing database information.
      • createDatabase

        public final void createDatabase()
                                  throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Creates a new database, connection remains attached to database.
        Specified by:
        createDatabase in interface FbDatabase
        Throws:
        java.sql.SQLException
      • dropDatabase

        public final void dropDatabase()
                                throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Drops (and deletes) the currently attached database.
        Specified by:
        dropDatabase in interface FbDatabase
        Throws:
        java.sql.SQLException
      • startTransaction

        public final FbWireTransaction startTransaction​(TransactionParameterBuffer tpb)
                                                 throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Creates and starts a transaction.
        Specified by:
        startTransaction in interface FbDatabase
        Parameters:
        tpb - TransactionParameterBuffer with the required transaction options
        Returns:
        FbTransaction
        Throws:
        java.sql.SQLException
      • reconnectTransaction

        public final FbTransaction reconnectTransaction​(long transactionId)
                                                 throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Reconnects a prepared transaction.

        Reconnecting transactions is only allowed for transactions in limbo (prepared, but not committed or rolled back).

        Specified by:
        reconnectTransaction in interface FbDatabase
        Parameters:
        transactionId - The id of the transaction to reconnect.
        Returns:
        FbTransaction
        Throws:
        java.sql.SQLException - For errors reconnecting the transaction
      • getTransactionIdBuffer

        protected byte[] getTransactionIdBuffer​(long transactionId)
      • createStatement

        public final FbStatement createStatement​(FbTransaction transaction)
                                          throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Creates a statement associated with a transaction
        Specified by:
        createStatement in interface FbDatabase
        Parameters:
        transaction - FbTransaction to associate with this statement (can be null)
        Returns:
        FbStatement
        Throws:
        java.sql.SQLException
      • cancelOperation

        public void cancelOperation​(int kind)
                             throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Cancels the current operation.

        The cancellation types are:

        ISCConstants.fb_cancel_disable
        disables execution of fb_cancel_raise requests for the specified attachment. It can be useful when your program is executing critical operations, such as cleanup, for example.
        ISCConstants.fb_cancel_enable
        re-enables delivery of a cancel execution that was previously disabled. The 'cancel' state is effective by default, being initialized when the attachment is created.
        ISCConstants.fb_cancel_raise
        cancels any activity related to the database handle. The effect will be that, as soon as possible, the engine will try to stop the running request and return an exception to the caller
        ISCConstants.fb_cancel_abort
        forcibly close client side of connection. Useful if you need to close a connection urgently. All active transactions will be rolled back by the server. 'Success' is always returned to the application. Use with care!

        Specified by:
        cancelOperation in interface FbDatabase
        Parameters:
        kind - Cancellation type
        Throws:
        java.sql.SQLException - For errors cancelling, or if the cancel operation is not supported.
      • executeImmediate

        public final void executeImmediate​(java.lang.String statementText,
                                           FbTransaction transaction)
                                    throws java.sql.SQLException
        Description copied from interface: FbDatabase
        Performs an execute immediate of a statement.

        A call to this method is the equivalent of a isc_dsql_execute_immediate() without parameters.

        Specified by:
        executeImmediate in interface FbDatabase
        Parameters:
        statementText - Statement text
        transaction - Transaction (null only allowed if database is not attached!)
        Throws:
        java.sql.SQLException - For errors executing the statement, or if transaction is null when the database is attached or not null when the database is not attached
      • releaseObject

        public void releaseObject​(int operation,
                                  int objectId)
                           throws java.sql.SQLException
        Description copied from interface: FbWireDatabase
        Release object.
        Specified by:
        releaseObject in interface FbWireDatabase
        Parameters:
        operation - Operation
        objectId - ID of the object to release
        Throws:
        java.sql.SQLException
      • doReleaseObjectPacket

        protected final void doReleaseObjectPacket​(int operation,
                                                   int objectId)
                                            throws java.io.IOException,
                                                   java.sql.SQLException
        Sends - without flushing - the (release) operation and objectId.
        Parameters:
        operation - Operation
        objectId - Id of the object to release
        Throws:
        java.io.IOException - For errors writing to the connection
        java.sql.SQLException - If the database connection is not available
      • processReleaseObjectResponse

        protected final void processReleaseObjectResponse​(Response response)
        Process the release object response
        Parameters:
        response - The response object
      • authReceiveResponse

        public final void authReceiveResponse​(FbWireAttachment.AcceptPacket acceptPacket)
                                       throws java.io.IOException,
                                              java.sql.SQLException
        Description copied from interface: FbWireAttachment
        Receive authentication response from the server.

        This method is only relevant for protocol V13 or higher.

        Specified by:
        authReceiveResponse in interface FbWireAttachment
        Parameters:
        acceptPacket - Packet with op_cond_accept data, or null when the data should be read from the connection.
        Throws:
        java.io.IOException - For errors reading the response from the connection.
        java.sql.SQLException - For errors returned from the server, or when attempting to read.