Package net.jextra.fauxjo.transaction
Class Transaction
- java.lang.Object
-
- net.jextra.fauxjo.transaction.Transaction
-
- All Implemented Interfaces:
Closeable,AutoCloseable,TransactionInterface
public class Transaction extends Object implements TransactionInterface
A clean convience class to manage a typical single database "transaction".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTransaction.TransactionListener
-
Constructor Summary
Constructors Constructor Description Transaction(Connection connection)Transaction(Connection connection, String savepointName)Transaction(Connection connection, Transaction.TransactionListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This should usually be called in a finally block, or anywhere it is unknown if acommit()orrollback()has been called.voidcommit()ConnectiongetConnection()SavepointgetSavepoint()voidrollback()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.jextra.fauxjo.transaction.TransactionInterface
finish
-
-
-
-
Constructor Detail
-
Transaction
public Transaction(Connection connection)
-
Transaction
public Transaction(Connection connection, Transaction.TransactionListener listener)
-
Transaction
public Transaction(Connection connection, String savepointName)
-
-
Method Detail
-
getSavepoint
public Savepoint getSavepoint()
-
rollback
public void rollback()
- Specified by:
rollbackin interfaceTransactionInterface
-
commit
public void commit()
- Specified by:
commitin interfaceTransactionInterface
-
close
public void close()
This should usually be called in a finally block, or anywhere it is unknown if acommit()orrollback()has been called. This will also restore the connection's autocommit state back to its previous value before the transaction.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTransactionInterface
-
getConnection
public Connection getConnection()
- Specified by:
getConnectionin interfaceTransactionInterface
-
-