Class SQLitePragmas

java.lang.Object
dev.rafex.ether.database.sqlite.config.SQLitePragmas

public final class SQLitePragmas extends Object
Utility to apply SQLite PRAGMA settings to a connection.

This class helps configure SQLite connections with optimal settings for performance, durability, and feature compatibility.

  • Method Details

    • apply

      public static void apply(Connection connection, SQLiteConfig config) throws SQLException
      Applies configuration to a SQLite connection.

      Executes the necessary PRAGMA statements to configure the connection according to the provided configuration.

      Parameters:
      connection - SQLite connection
      config - configuration to apply
      Throws:
      SQLException - if any PRAGMA statement fails
      NullPointerException - if connection or config is null
    • applyDefaults

      public static void applyDefaults(Connection connection) throws SQLException
      Applies default configuration to a SQLite connection.

      Equivalent to apply(connection, SQLiteConfig.defaults()).

      Parameters:
      connection - SQLite connection
      Throws:
      SQLException - if any PRAGMA statement fails
      NullPointerException - if connection is null
    • enableWal

      public static void enableWal(Connection connection) throws SQLException
      Enables Write-Ahead Logging (WAL) mode on a connection.

      This is a convenience method for enabling WAL mode specifically.

      Parameters:
      connection - SQLite connection
      Throws:
      SQLException - if the PRAGMA statement fails
      NullPointerException - if connection is null
    • disableWal

      public static void disableWal(Connection connection) throws SQLException
      Disables Write-Ahead Logging (WAL) mode on a connection.

      This is a convenience method for disabling WAL mode specifically.

      Parameters:
      connection - SQLite connection
      Throws:
      SQLException - if the PRAGMA statement fails
      NullPointerException - if connection is null
    • setSynchronousMode

      public static void setSynchronousMode(Connection connection, SynchronousMode mode) throws SQLException
      Sets the synchronous mode on a connection.

      This is a convenience method for setting synchronous mode specifically.

      Parameters:
      connection - SQLite connection
      mode - synchronous mode
      Throws:
      SQLException - if the PRAGMA statement fails
      NullPointerException - if connection or mode is null