Class Database
java.lang.Object
com.github.darksoulq.abyssallib.common.database.relational.AbstractDatabase
com.github.darksoulq.abyssallib.common.database.relational.mariadb.Database
A MariaDB database implementation managing remote JDBC connections.
This class includes a background scheduler to maintain connection stability
through periodic keep-alive checks and provides thread-safe access to the
underlying Connection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Establishes the connection and starts the 30-minute keep-alive interval.voidGracefully shuts down the scheduler, async pool, and JDBC connection.executor()Spawns an executor for this database.Synchronized getter for the connection; performs a health check and auto-reconnects if the connection is dead.voidtransaction(Consumer<QueryExecutor> action) Executes a series of operations within a transactional scope.<T> TtransactionResult(Function<QueryExecutor, T> action) Executes a series of operations within a transactional scope and returns a value.Methods inherited from class AbstractDatabase
executeTransaction, executeTransactionResult, getAsyncPool
-
Constructor Details
-
Database
-
-
Method Details
-
connect
-
disconnect
-
getConnection
Synchronized getter for the connection; performs a health check and auto-reconnects if the connection is dead.- Specified by:
getConnectionin classAbstractDatabase- Returns:
- A valid
Connection. - Throws:
SQLException- If the database is unreachable.
-
executor
-
transaction
Executes a series of operations within a transactional scope.- Parameters:
action- The logic to execute.
-
transactionResult
Executes a series of operations within a transactional scope and returns a value.- Type Parameters:
T- The result type.- Parameters:
action- The logic to execute.- Returns:
- The result of type
T.
-