org.firebirdsql.gds.ng.jna

## Class JnaTransaction

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractFbTransaction
  - - org.firebirdsql.gds.ng.jna.JnaTransaction

- All Implemented Interfaces:
    FbTransaction, ExceptionListenable

      public class JnaTransaction
      extends AbstractFbTransaction

  Implementation of `FbTransaction` for native client access.
  Since:
    3.0
  Author:
    Mark Rotteveel

- - ### Field Summary

    - ### Fields inherited from class org.firebirdsql.gds.ng.AbstractFbTransaction

      `exceptionListenerDispatcher, transactionListenerDispatcher`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JnaTransaction(JnaDatabase database, com.sun.jna.ptr.IntByReference transactionHandle, TransactionState initialState)` Initializes AbstractFbTransaction.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `commit()` Commit the transaction
    `JnaDatabase` | `getDatabase()`
    `int` | `getHandle()`
    `com.sun.jna.ptr.IntByReference` | `getJnaHandle()`
    `byte[]` | `getTransactionInfo(byte[] requestItems, int maxBufferLength)` Performs a transaction info request.
    `void` | `prepare(byte[] recoveryInformation)` Prepare the transaction for two-phase commit/rollback.
    `void` | `rollback()` Roll back the transaction

    - ### Methods inherited from class org.firebirdsql.gds.ng.AbstractFbTransaction

      `addExceptionListener, addTransactionListener, addWeakTransactionListener, finalize, getState, getSynchronizationObject, getTransactionId, getTransactionInfo, removeExceptionListener, removeTransactionListener, switchState`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JnaTransaction

          public JnaTransaction(JnaDatabase database,
                                com.sun.jna.ptr.IntByReference transactionHandle,
                                TransactionState initialState)

      Initializes AbstractFbTransaction.
      Parameters:
        `database` - FbDatabase that created this handle.
        `transactionHandle` - Transaction handle
        `initialState` - Initial transaction state (allowed values are `TransactionState.ACTIVE` and `TransactionState.PREPARED`.

  - ### Method Detail

    - #### getDatabase

          public JnaDatabase getDatabase()

      Overrides:
        `getDatabase` in class `AbstractFbTransaction`

    - #### getHandle

          public int getHandle()

      Returns:
        The Firebird transaction handle identifier

    - #### getJnaHandle

          public com.sun.jna.ptr.IntByReference getJnaHandle()

    - #### commit

          public void commit()
                      throws java.sql.SQLException

      Description copied from interface: `FbTransaction`
      Commit the transaction
      Throws:
        `java.sql.SQLException`

    - #### rollback

          public void rollback()
                        throws java.sql.SQLException

      Description copied from interface: `FbTransaction`
      Roll back the transaction
      Throws:
        `java.sql.SQLException`

    - #### prepare

          public void prepare(byte[] recoveryInformation)
                       throws java.sql.SQLException

      Description copied from interface: `FbTransaction`
      Prepare the transaction for two-phase commit/rollback.
      Parameters:
        `recoveryInformation` - Transaction recovery information (stored in RDB$TRANSACTION_DESCRIPTION of RDB$TRANSACTIONS), or `null` to prepare without recovery information.
      Throws:
        `java.sql.SQLException`

    - #### getTransactionInfo

          public byte[] getTransactionInfo(byte[] requestItems,
                                           int maxBufferLength)
                                    throws java.sql.SQLException

      Description copied from interface: `FbTransaction`
      Performs a transaction info request.
      Parameters:
        `requestItems` - Information items to request
        `maxBufferLength` - Maximum response buffer length to use
      Returns:
        The response buffer (note: length is the actual length of the response, not `maxBufferLength`
      Throws:
        `java.sql.SQLException` - For errors retrieving the information.

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.