java.lang.Object
com.inductiveautomation.ignition.gateway.localdb.hsql.HsqlDbManager
All Implemented Interfaces:
DBManager

public class HsqlDbManager extends Object implements DBManager
  • Field Details

    • LOGGER_NAME

      public static final String LOGGER_NAME
      See Also:
    • context

      protected GatewayContext context
    • dbDir

      protected File dbDir
      The home directory that the database lives in
    • autoBackupDir

      protected File autoBackupDir
    • dbName

      protected String dbName
      The name of the HSQLDB database
    • faultCount

      protected int faultCount
      Number of faulted copies to keep
    • autoBackupCount

      protected int autoBackupCount
      Number of auto-backups to keep, if autoBackupsEnabled is true
    • autoBackupDelay

      protected int autoBackupDelay
      Delay, in minutes, between checking if an auto-backup is necessary.
    • defragDelay

      protected int defragDelay
      Delay, in minutes, between defragmentation. If 0, defrag checkpoints will not be executed. *
    • autoBackupsEnabled

      protected boolean autoBackupsEnabled
      Whether or not to use any autobackups. Note that setting this to false doesn net prevent the creation of autobackups - for that you'd set autoBackupCount to zero.
    • password

      protected String password
      The password for the "sa" user for the database
    • datasource

      protected CountingDataSource datasource
      When this manager is connected, this will be a non-null reference to a javax.sql.DataSource that can be used to get connections to the database
    • newDatabase

      protected boolean newDatabase
      Flag that will be set true when this managaer was started up with no database and created an initial one on connect()
    • log

      protected LoggerEx log
  • Constructor Details

  • Method Details

    • initDriver

      public void initDriver() throws DBStartupException
      Throws:
      DBStartupException
    • newLogger

      protected LoggerEx newLogger()
    • createConnectionProps

      protected Properties createConnectionProps()
    • startup

      public void startup() throws DBStartupException
      Specified by:
      startup in interface DBManager
      Throws:
      DBStartupException
    • archiveDatabaseTo

      public void archiveDatabaseTo(String folderName, boolean clear) throws Exception
      Throws:
      Exception
    • getDataSource

      public DataSource getDataSource()
      Specified by:
      getDataSource in interface DBManager
    • checkpoint

      public void checkpoint()
    • onCreateInitial

      protected void onCreateInitial(Statement stmt) throws SQLException
      Called on creation of a new database, after the password has been set.
      Throws:
      SQLException
    • onConnected

      protected void onConnected(DataSource datasource) throws SQLException
      Called after we have been successfully connected to an HSQLDB database. A CHECKPOINT will be issued after this completes.
      Throws:
      SQLException
    • onShutdown

      protected void onShutdown()
    • desc

      protected String desc()
    • restoreFromDBBackup

      public void restoreFromDBBackup(File dbBackupTarball) throws IOException
      Deletes the database files and extracts the tarball into the database home directory.
      Specified by:
      restoreFromDBBackup in interface DBManager
      Throws:
      IOException
    • backupDatabase

      public File backupDatabase(File targetFolder, String baseFilename) throws IOException
      Description copied from interface: DBManager
      Creates a single-file backup of the internal db in the specified folder. The full path to the backup is returned. The filename should start with the base, but should then be identifiable by the specific db system.
      Specified by:
      backupDatabase in interface DBManager
      Throws:
      IOException
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface DBManager
    • isNewDatabase

      public boolean isNewDatabase()
      Specified by:
      isNewDatabase in interface DBManager
    • shutdown

      public void shutdown()
    • getDatabaseSize

      public long getDatabaseSize()
      Calculates the harddrive footprint of the files that make up this HSQLDB instance.
      Specified by:
      getDatabaseSize in interface DBManager
    • shutdown

      public void shutdown(boolean compact)
      Specified by:
      shutdown in interface DBManager
    • getAutoBackupDir

      public File getAutoBackupDir()
    • setAutoBackupDir

      public void setAutoBackupDir(File autoBackupDir)
    • getFaultCount

      public int getFaultCount()
    • setFaultCount

      public void setFaultCount(int faultCount)
      Specified by:
      setFaultCount in interface DBManager
    • getAutoBackupCount

      public int getAutoBackupCount()
    • setAutoBackupCount

      public void setAutoBackupCount(int autoBackupCount)
      Specified by:
      setAutoBackupCount in interface DBManager
    • isAutoBackupsEnabled

      public boolean isAutoBackupsEnabled()
    • setAutoBackupsEnabled

      public void setAutoBackupsEnabled(boolean autoBackupsEnabled)
      Specified by:
      setAutoBackupsEnabled in interface DBManager
    • getAutoBackupDelay

      public int getAutoBackupDelay()
    • setAutoBackupDelay

      public void setAutoBackupDelay(int autoBackupDelay)
      Specified by:
      setAutoBackupDelay in interface DBManager
    • setDefragDelay

      public void setDefragDelay(int defragDelayMin)
      Specified by:
      setDefragDelay in interface DBManager
    • getFlavor

      public InternalDBFlavor getFlavor()
      Specified by:
      getFlavor in interface DBManager
    • getDriver

      public SDriver getDriver()
      Description copied from interface: DBManager
      Returns the driver for the DBManager. Important: the driver holds a session, so a new instance should be created each time.
      Specified by:
      getDriver in interface DBManager
    • createTable

      public Table createTable()
      Specified by:
      createTable in interface DBManager