Klasse Database
java.lang.Object
de.delinkedde.areashopreborn.persistence.Database
- Alle implementierten Schnittstellen:
AutoCloseable
Owns the SQLite connection configuration and single-threaded database executor.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic final recordMinimal verification result read directly from a backup file.static interfaceRepresents a checked database operation without a return value.static interfaceRepresents a checked value-producing database operation. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungintCreates a transactionally consistent standalone SQLite snapshot.voidclose()Stops accepting database work and waits briefly for queued operations.longEstimates the largest normal SQLite snapshot from the current page count.inspect()Runs SQLite integrity, migration, and journal-mode checks on a caller-selected thread.static Database.BackupStatusinspectBackup(Path backup) Inspects an existing standalone SQLite backup without modifying journal mode.Opens a configured SQLite connection with foreign keys, WAL, and a busy timeout enabled.runAsync(Database.SqlRunnable runnable) Runs a database operation on the dedicated database thread.<T> CompletableFuture<T> supplyAsync(Database.SqlSupplier<T> supplier) Runs a value-producing database operation on the dedicated database thread.
-
Konstruktordetails
-
Database
public Database(org.bukkit.plugin.java.JavaPlugin plugin, String fileName) throws IOException, SQLException Opens or creates the configured SQLite database and applies migrations.- Parameter:
plugin- owning pluginfileName- database file relative to the plugin data directory- Löst aus:
IOException- when the data directory or migration resource cannot be readSQLException- when SQLite initialization fails
-
-
Methodendetails
-
openConnection
Opens a configured SQLite connection with foreign keys, WAL, and a busy timeout enabled.- Gibt zurück:
- new caller-owned connection
- Löst aus:
SQLException- when a connection cannot be established
-
inspect
Runs SQLite integrity, migration, and journal-mode checks on a caller-selected thread.- Gibt zurück:
- immutable database status
- Löst aus:
SQLException- when SQLite cannot perform the inspection
-
backupTo
Creates a transactionally consistent standalone SQLite snapshot.This method must run on the database executor. SQLite
VACUUM INTOincludes committed WAL content without copying live-walor-shmfiles.- Parameter:
target- new snapshot file- Gibt zurück:
- highest schema migration stored in the verified snapshot
- Löst aus:
IOException- when the target directory cannot be preparedSQLException- when snapshot creation or integrity verification fails
-
estimatedBackupSizeBytes
Estimates the largest normal SQLite snapshot from the current page count.The estimate is deliberately conservative because
VACUUM INTOcan compact unused pages. It allows callers to reject snapshots that exceed their disk budget before SQLite starts writing the target file.- Gibt zurück:
- current database page count multiplied by its page size
- Löst aus:
SQLException- when SQLite metadata cannot be read
-
inspectBackup
Inspects an existing standalone SQLite backup without modifying journal mode.- Parameter:
backup- snapshot file to inspect- Gibt zurück:
- integrity and schema status
- Löst aus:
IOException- when the path is not a regular fileSQLException- when SQLite cannot inspect the snapshot
-
supplyAsync
Runs a value-producing database operation on the dedicated database thread.- Typparameter:
T- result type- Parameter:
supplier- operation to execute- Gibt zurück:
- future completed with the operation result
-
runAsync
Runs a database operation on the dedicated database thread.- Parameter:
runnable- operation to execute- Gibt zurück:
- completion future
-
close
public void close()Stops accepting database work and waits briefly for queued operations.- Angegeben von:
closein SchnittstelleAutoCloseable
-