java.lang.Object
no.ntnu.principes.config.SQLiteDatabaseConfig
- All Implemented Interfaces:
DatabaseConfig
SQLite implementation of the DatabaseConfig interface.
Creates and manages a SQLite database connection with write-ahead logging,
foreign key enforcement, and busy timeout handling.
Uses a thread-safe singleton pattern for the data source.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCreates a backup of the database to the specified path.static voidCloses the data source by setting it to null.static DataSourceGets the SQLite data source using double-checked locking for thread safety.
-
Constructor Details
-
SQLiteDatabaseConfig
public SQLiteDatabaseConfig()
-
-
Method Details
-
getDataSource
Gets the SQLite data source using double-checked locking for thread safety. Initializes the data source if it hasn't been created yet.- Returns:
- The SQLite data source
-
backup
Creates a backup of the database to the specified path. Uses SQLite's built-in backup command.- Parameters:
backupPath- The path where the backup will be saved- Throws:
RuntimeException- If the backup operation fails
-
closeDataSource
public static void closeDataSource()Closes the data source by setting it to null. SQLite doesn't require explicit closure, but this method is provided for consistency.
-