Class H2DatabaseFactory

java.lang.Object
is.codion.dbms.h2.H2DatabaseFactory
All Implemented Interfaces:
DatabaseFactory

public final class H2DatabaseFactory extends Object implements DatabaseFactory
Provides h2 database implementations
  • Constructor Details

    • H2DatabaseFactory

      public H2DatabaseFactory()
  • Method Details

    • driverCompatible

      public boolean driverCompatible(String driverClassName)
      Specified by:
      driverCompatible in interface DatabaseFactory
      Parameters:
      driverClassName - the driver class name
      Returns:
      true if this database factory is compatible with the given driver
    • create

      public Database create(String url)
      Specified by:
      create in interface DatabaseFactory
      Parameters:
      url - the jdbc url
      Returns:
      a new Database implementation based on the given jdbc url.
    • createDatabase

      public static Database createDatabase(String url, String... initScripts)
      Creates a H2 Database instance
      Parameters:
      url - the jdbc url
      initScripts - initialization scripts to run on database creation
      Returns:
      a H2 Database instance
    • runScript

      public static void runScript(Database database, String scriptPath) throws SQLException
      Runs the given script using the RunScript tool, with the default sysadmin username (sa) and default charset
      Parameters:
      database - the database
      scriptPath - the path to the script
      Throws:
      SQLException - in case of an exception
    • runScript

      public static void runScript(Database database, String scriptPath, String username, String password, Charset scriptCharset) throws SQLException
      Runs the given script using the RunScript tool
      Parameters:
      database - the database
      scriptPath - the path to the script
      username - the username to run the script under
      password - the password
      scriptCharset - the script character set
      Throws:
      SQLException - in case of an exception