org.midao.jdbc.core.transaction
Interface TransactionHandler

All Known Implementing Classes:
BaseTransactionHandler

public interface TransactionHandler

Transaction Handler definition. Used by QueryRunnerService to handle Connection retrieval/initialization, Transactions: Commit/Rollback, Modes and Isolation's.


Method Summary
 void closeConnection()
          Informs Transaction Handler that connection is no longer used.
 void commit()
          Commits current Transaction Usable only when setManualMode(boolean) set as true
 java.sql.Connection getConnection()
          Returns wrapped(proxy) connection.
 java.lang.Integer getIsolationLevel()
          Returns current Transaction Isolation level
 boolean getManualMode()
          Returns current Transaction mode
 TransactionHandler newInstance(java.sql.Connection conn)
          Creates new TransactionHandler instance.
 TransactionHandler newInstance(javax.sql.DataSource ds)
          Creates new TransactionHandler instance.
 void releaseSavepoint(java.sql.Savepoint savepoint)
          Removes the specified Savepoint and subsequent Savepoint objects from the current transaction.
 void rollback()
          Rollbacks current Transaction Usable only when setManualMode(boolean) set as true
 void rollback(java.sql.Savepoint savepoint)
          Undoes all changes made after the given Savepoint object was set.
 void setIsolationLevel(java.lang.Integer level)
          Transaction Isolation level.
 void setManualMode(boolean manualMode)
          Allows switching on/off Manual Transaction mode.
 java.sql.Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 java.sql.Savepoint setSavepoint(java.lang.String name)
          Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
 

Method Detail

newInstance

TransactionHandler newInstance(java.sql.Connection conn)
Creates new TransactionHandler instance. Might be removed in future

Parameters:
conn - SQL Connection
Returns:

newInstance

TransactionHandler newInstance(javax.sql.DataSource ds)
Creates new TransactionHandler instance. Might be removed in future

Parameters:
ds - SQL DataSource
Returns:

setManualMode

void setManualMode(boolean manualMode)
Allows switching on/off Manual Transaction mode. This allows to group more that one operation into one Transaction and allows commit/rollback transaction manually

Parameters:
manualMode - new Transaction Mode

getManualMode

boolean getManualMode()
Returns current Transaction mode

Returns:
current Transaction mode

setIsolationLevel

void setIsolationLevel(java.lang.Integer level)
Transaction Isolation level. For general information please look at Java Tutorials (docs.oracle.com/javase/tutorial/index.html) JDBC basics / Using Transactions For detailed information please look at vendor JDBC driver description

Parameters:
level - Transaction Isolation level

getIsolationLevel

java.lang.Integer getIsolationLevel()
Returns current Transaction Isolation level

Returns:
current Transaction Isolation level

getConnection

java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns wrapped(proxy) connection. Proxy protects Connection from being closed as this is managed by Transaction Handler already and might create exception if Connection would be closed outside it. In case you need to perform some unorthodox manipulation with it - it is allowed simply to be casted to Implementation class.

Returns:
Proxy of SQL Connection
Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

closeConnection

void closeConnection()
Informs Transaction Handler that connection is no longer used. Actual close might not be performed as it depends on TransactionHandler mode.


commit

void commit()
            throws java.sql.SQLException
Commits current Transaction Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

rollback

void rollback()
              throws java.sql.SQLException
Rollbacks current Transaction Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

setSavepoint

java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. Connection.setSavepoint() Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

setSavepoint

java.sql.Savepoint setSavepoint(java.lang.String name)
                                throws java.sql.SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. Connection.setSavepoint(String) Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

rollback

void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Undoes all changes made after the given Savepoint object was set. Connection.rollback(java.sql.Savepoint) Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database

releaseSavepoint

void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Removes the specified Savepoint and subsequent Savepoint objects from the current transaction. Connection.releaseSavepoint(java.sql.Savepoint) Usable only when setManualMode(boolean) set as true

Throws:
java.sql.SQLException - if exception would be thrown by Driver/Database


Copyright © 2013. All Rights Reserved.