|
DataBridge Documentation 2.0.18
A Java library for managing database connections and transactions
|
Public Member Functions | |
| void | begin () throws SQLException |
| void | close () throws SQLException |
| void | commit () throws SQLException |
| void | rollback () throws SQLException |
| Transaction (DatabaseConnection dbConnection) throws SQLException | |
The Transaction class is responsible for managing database transactions. It supports beginning, committing, and rolling back transactions using a provided DatabaseConnection. This class ensures that the transaction is properly managed, with methods to handle active transaction states, commit or roll back changes, and clean up after transactions.
| io.github.kdesp73.databridge.helpers.Transaction.Transaction | ( | DatabaseConnection | dbConnection | ) | throws SQLException |
Constructs a Transaction object using the provided DatabaseConnection. This constructor initializes the connection and sets auto-commit to false, preparing it for transaction management.
| dbConnection | the database connection to use for the transaction. |
| SQLException | if a database access error occurs or the connection is invalid. |
| void io.github.kdesp73.databridge.helpers.Transaction.begin | ( | ) | throws SQLException |
Starts a new transaction. This method ensures that no other transaction is currently active. If a transaction is already active, an SQLException will be thrown.
| SQLException | if a transaction is already active. |
| void io.github.kdesp73.databridge.helpers.Transaction.commit | ( | ) | throws SQLException |
Commits the current transaction, making all changes permanent in the database. If no active transaction exists, an SQLException will be thrown.
| SQLException | if no active transaction exists or if the commit fails. |
| void io.github.kdesp73.databridge.helpers.Transaction.rollback | ( | ) | throws SQLException |
Rolls back the current transaction, discarding all changes made during the transaction. If no active transaction exists, an SQLException will be thrown.
| SQLException | if no active transaction exists or if the rollback fails. |
| void io.github.kdesp73.databridge.helpers.Transaction.close | ( | ) | throws SQLException |
Closes the transaction manager, ensuring any active transaction is rolled back and the database connection is closed. If no active transaction exists, no rollback is performed.
| SQLException | if an error occurs during rollback or closing the connection. |