Class Database
java.lang.Object
com.github.darksoulq.abyssallib.common.database.relational.AbstractDatabase
com.github.darksoulq.abyssallib.common.database.relational.sql.Database
A SQLite database implementation that manages the file lifecycle and connection state.
It uses a cached thread pool for asynchronous operations and enforces foreign key constraints by default.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Establishes a connection to the SQLite database.voidCloses the database connection and shuts down the asynchronous thread pool.executor()Creates a new QueryExecutor instance tied to this database's connection and thread pool.Retrieves the currently active SQLite connection.voidtransaction(Consumer<QueryExecutor> action) Executes a set of operations within a SQL transaction.<T> TtransactionResult(Function<QueryExecutor, T> action) Executes a set of operations within a SQL transaction and returns a result.Methods inherited from class AbstractDatabase
executeTransaction, executeTransactionResult, getAsyncPool
-
Constructor Details
-
Database
-
-
Method Details
-
connect
-
disconnect
-
getConnection
Retrieves the currently active SQLite connection.- Specified by:
getConnectionin classAbstractDatabase- Returns:
- The
Connectioninstance.
-
executor
Creates a new QueryExecutor instance tied to this database's connection and thread pool.- Returns:
- A new
QueryExecutorfor performing database operations.
-
transaction
Executes a set of operations within a SQL transaction. The operations are performed via aQueryExecutor.- Parameters:
action- AConsumerproviding aQueryExecutorwithin the transaction scope.
-
transactionResult
Executes a set of operations within a SQL transaction and returns a result.- Type Parameters:
T- The type of the result.- Parameters:
action- AFunctionproviding aQueryExecutorand returning a value of typeT.- Returns:
- The result of the transaction.
-