toolbox.dao
Class TransactionCtxImpl

Package class diagram package TransactionCtxImpl
java.lang.Object
  extended by toolbox.dao.TransactionCtxImpl
All Implemented Interfaces:
TransactionContext

public class TransactionCtxImpl
extends java.lang.Object
implements TransactionContext

Default implementation of the TransactionContext interface. Provides implementation for all methods of the interface.


Constructor Summary
TransactionCtxImpl()
          Default constructor
 
Method Summary
 void commit()
          Commits the transaction.
 java.sql.Connection getConnection()
          Returns the connection used by this context.
 void rollback()
          Rolls back the transaction.
 void setConnection(java.sql.Connection conn)
          Set the connection that this context will use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionCtxImpl

public TransactionCtxImpl()
Default constructor

Method Detail

setConnection

public void setConnection(java.sql.Connection conn)
                   throws DaoException
Set the connection that this context will use. This method ensures that auto commit is turned off.

Specified by:
setConnection in interface TransactionContext
Parameters:
conn - Connection this context will use for Database communication.
Throws:
DaoException - if the connection cannot be prepared for transactional purposes.

getConnection

public java.sql.Connection getConnection()
Returns the connection used by this context.

Specified by:
getConnection in interface TransactionContext
Returns:
Connection used by this context.

commit

public void commit()
            throws DaoException
Commits the transaction.

Specified by:
commit in interface TransactionContext
Throws:
DaoException - if the transaction cannot be committed.

rollback

public void rollback()
              throws DaoException
Rolls back the transaction.

Specified by:
rollback in interface TransactionContext
Throws:
DaoException - if transaction cannot be rolled back.