DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.helpers.Transaction Class Reference

Public Member Functions

void begin () throws SQLException
 
void close () throws SQLException
 
void commit () throws SQLException
 
void rollback () throws SQLException
 
 Transaction (DatabaseConnection dbConnection) throws SQLException
 

Detailed Description

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.

Author
KDesp73

Constructor & Destructor Documentation

◆ Transaction()

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.

Parameters
dbConnectionthe database connection to use for the transaction.
Exceptions
SQLExceptionif a database access error occurs or the connection is invalid.

Member Function Documentation

◆ begin()

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.

Exceptions
SQLExceptionif a transaction is already active.

◆ commit()

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.

Exceptions
SQLExceptionif no active transaction exists or if the commit fails.

◆ rollback()

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.

Exceptions
SQLExceptionif no active transaction exists or if the rollback fails.

◆ close()

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.

Exceptions
SQLExceptionif an error occurs during rollback or closing the connection.

The documentation for this class was generated from the following file: