Class SQLiteDatabaseConfig

java.lang.Object
no.ntnu.principes.config.SQLiteDatabaseConfig
All Implemented Interfaces:
DatabaseConfig

public class SQLiteDatabaseConfig extends Object implements 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 Details

    • SQLiteDatabaseConfig

      public SQLiteDatabaseConfig()
  • Method Details

    • getDataSource

      public static DataSource 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

      public static void backup(Path backupPath)
      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.