org.sormula
Class Transaction

java.lang.Object
  extended by org.sormula.Transaction
Direct Known Subclasses:
OperationTransaction

public class Transaction
extends java.lang.Object

Simple transaction interface for Connection. This class is not required for any sormula programming and is only used by Database as a convenience. Other transaction mechanisms are compatible with sormula.

Author:
Jeff Miller

Constructor Summary
Transaction(java.sql.Connection connection)
          Constructs for a connection.
 
Method Summary
 void begin()
          Starts the transaction.
protected  void cleanUp()
          Sets isActive() to false and restores auto commit to the original state.
 void commit()
          Commits the transaction by invoking Connection.commit().
 java.sql.Connection getConnection()
          Gets the connection supplied in the constructor.
 boolean isActive()
          Reports if transaction is ongoing.
 void rollback()
          Aborts the transaction by invoking Connection.rollback().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public Transaction(java.sql.Connection connection)
Constructs for a connection.

Parameters:
connection - JDBC connection
Method Detail

getConnection

public java.sql.Connection getConnection()
Gets the connection supplied in the constructor.

Returns:
connect for this transaction

isActive

public boolean isActive()
Reports if transaction is ongoing.

Returns:
true if begin() has been invoked but not commit() or rollback()

begin

public void begin()
           throws SormulaException
Starts the transaction.

Throws:
SormulaException - if error

commit

public void commit()
            throws SormulaException
Commits the transaction by invoking Connection.commit().

Throws:
SormulaException - if error

rollback

public void rollback()
              throws SormulaException
Aborts the transaction by invoking Connection.rollback().

Throws:
SormulaException

cleanUp

protected void cleanUp()
Sets isActive() to false and restores auto commit to the original state.