com.isomorphic.sql

## Class SQLTransaction

- com.isomorphic.sql.SQLTransaction

-     public class SQLTransaction

  A class containing various static methods for managing transactional updates on SQL DataSources. This class is part of the Automatic Transactions feature, which is effective only in Power edition and above.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `commitTransaction(RPCManager rpc)` Commit the current transaction
    `static void` | `endTransaction(RPCManager rpc)` End the current transaction.
    `static java.sql.Connection` | `getConnection(RPCManager rpc)` Returns the connection participating in the transaction.
    `static void` | `rollbackTransaction(RPCManager rpc)` Rollback the current transaction
    `static void` | `setAutoEndTransactions(boolean autoEnd)` Sets automatic transaction end support.
    `static boolean` | `startTransaction(RPCManager rpc)` Starts a new database transaction.

- - ### Method Detail

    - #### setAutoEndTransactions

          public static void setAutoEndTransactions(boolean autoEnd)

      Sets automatic transaction end support. When this is on, transaction support is ended when you commit or rollback a transaction; any further database operations in this HTTP request will be auto-committed. When this is off, transaction support persists beyond a commit or rollback boundary, so further database operations in this HTTP request will be part of a new transaction and must be committed manually. By default, automatic transaction end support is off. This means that your code is responsible for calling endTransaction().
      Parameters:
        `autoEnd` - If true, switches on auto-end support

    - #### startTransaction

          public static boolean startTransaction(RPCManager rpc)
                                          throws java.lang.Exception

      Starts a new database transaction. Note that when you use transactional support, your code is responsible for calling endTransaction() - if you neglect to do so, you will cause connection leaks. It is possible to have the transaction manager end transactions automatically for you after a commit or rollback - this facility is controlled by the static SQLTransaction.setAutoEndTransactions() method.
      Throws:
        `java.lang.Exception`

    - #### getConnection

          public static java.sql.Connection getConnection(RPCManager rpc)
                                                   throws java.lang.Exception

      Returns the connection participating in the transaction. This will be null until startTransaction() is called.
      Throws:
        `java.lang.Exception` - if there is a configuration error with one of the underlying datasources

    - #### rollbackTransaction

          public static void rollbackTransaction(RPCManager rpc)
                                          throws java.lang.Exception

      Rollback the current transaction
      Throws:
        `java.lang.Exception` - if problems were found rolling back the transaction

    - #### commitTransaction

          public static void commitTransaction(RPCManager rpc)
                                        throws java.lang.Exception

      Commit the current transaction
      Throws:
        `java.lang.Exception` - if problems were found committing the transaction

    - #### endTransaction

          public static void endTransaction(RPCManager rpc)
                                     throws java.lang.Exception

      End the current transaction. "Ending" a transaction simply means surrendering the database connection we are using to represent the transaction back to the pool. Any further database operations in this HTTP request will take place on an auto-commit basis, unless you issue another startTransaction call. Note that startTransaction() calls MUST be paired with endTransaction() calls, unless you have set the transaction manager into auto-end mode (see SQLTransaction.setAutoEndTransactions()).
      Throws:
        `java.lang.Exception` - if problems were found ending the transaction