Class SQLiteDBManager
java.lang.Object
com.inductiveautomation.ignition.gateway.localdb.sqlite.SQLiteDBManager
- All Implemented Interfaces:
- DBManager
Created by colby.clegg on 11/12/2015.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intNumber of auto-backups to keep, if autoBackupsEnabled is trueprotected intDelay, in minutes, between checking if an auto-backup is necessary.protected Fileprotected booleanWhether or not to use any autobackups.protected CountingDataSourceWhen 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 databaseprotected FileThe home directory that the database lives inprotected StringThe name of the databaseprotected intDelay, in minutes, between defragmentation.static final Stringprotected intNumber of faulted copies to keepprotected LoggerExprotected booleanFlag that will be set true when this manager was started up with no database and created an initial one on connect()
- 
Constructor SummaryConstructorsConstructorDescriptionSQLiteDBManager(ExecutionManager executionManager, Supplier<ContextState> gatewayState, File dbDir, String dbName) 
- 
Method SummaryModifier and TypeMethodDescriptionbackupDatabase(File targetFolder, String baseFilename) Creates a single-file backup of the internal db in the specified folder.static SQLiteDBManagercreate(GatewayContext context, File dbDir, String filename) protected Stringprotected booleanprotected Stringdesc()intintlongCalculates the harddrive footprint of the files that make up this sqlite instance.Returns the driver for the DBManager.intvoidbooleanbooleanbooleanprotected voidonConnected(DataSource datasource) Called after we have been successfully connected to a sqlite database.protected voidonCreateInitial(Statement stmt) Called on creation of a new database, after the password has been set.protected voidvoidrestoreFromDBBackup(File dbFile) Deletes the database files and restores the provided db filevoidsetAutoBackupCount(int autoBackupCount) voidsetAutoBackupDelay(int autoBackupDelay) voidsetAutoBackupDir(File autoBackupDir) voidsetAutoBackupsEnabled(boolean autoBackupsEnabled) voidsetDefragDelay(int defragDelayMin) voidsetFaultCount(int faultCount) voidshutdown()voidshutdown(boolean compact) voidstartup()
- 
Field Details- 
DRIVER_CLASS- See Also:
 
- 
dbDirThe home directory that the database lives in
- 
autoBackupDir
- 
dbNameThe name of the database
- 
faultCountprotected int faultCountNumber of faulted copies to keep
- 
autoBackupCountprotected int autoBackupCountNumber of auto-backups to keep, if autoBackupsEnabled is true
- 
autoBackupDelayprotected int autoBackupDelayDelay, in minutes, between checking if an auto-backup is necessary.
- 
defragDelayprotected int defragDelayDelay, in minutes, between defragmentation. If 0, defrag checkpoints will not be executed. *
- 
autoBackupsEnabledprotected boolean autoBackupsEnabledWhether 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.
- 
datasourceWhen 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
- 
newDatabaseprotected boolean newDatabaseFlag that will be set true when this manager was started up with no database and created an initial one on connect()
- 
log
 
- 
- 
Constructor Details- 
SQLiteDBManagerpublic SQLiteDBManager(ExecutionManager executionManager, Supplier<ContextState> gatewayState, File dbDir, String dbName) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 
- 
- 
Method Details- 
initDriver- Throws:
- DBStartupException
 
- 
createUrl
- 
startup- Specified by:
- startupin interface- DBManager
- Throws:
- DBStartupException
 
- 
getDataSource- Specified by:
- getDataSourcein interface- DBManager
 
- 
dbFilesExistprotected boolean dbFilesExist()
- 
onCreateInitialCalled on creation of a new database, after the password has been set.- Throws:
- SQLException
 
- 
onConnectedCalled after we have been successfully connected to a sqlite database.- Throws:
- SQLException
 
- 
onShutdownprotected void onShutdown()
- 
desc
- 
restoreFromDBBackupDeletes the database files and restores the provided db file- Specified by:
- restoreFromDBBackupin interface- DBManager
- Throws:
- IOException
 
- 
backupDatabaseDescription copied from interface:DBManagerCreates 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:
- backupDatabasein interface- DBManager
- Throws:
- IOException
 
- 
isRunningpublic boolean isRunning()
- 
isNewDatabasepublic boolean isNewDatabase()- Specified by:
- isNewDatabasein interface- DBManager
 
- 
shutdownpublic void shutdown()
- 
getDatabaseSizepublic long getDatabaseSize()Calculates the harddrive footprint of the files that make up this sqlite instance.- Specified by:
- getDatabaseSizein interface- DBManager
 
- 
shutdownpublic void shutdown(boolean compact) 
- 
getAutoBackupDir
- 
setAutoBackupDir
- 
getFaultCountpublic int getFaultCount()
- 
setFaultCountpublic void setFaultCount(int faultCount) - Specified by:
- setFaultCountin interface- DBManager
 
- 
getAutoBackupCountpublic int getAutoBackupCount()
- 
setAutoBackupCountpublic void setAutoBackupCount(int autoBackupCount) - Specified by:
- setAutoBackupCountin interface- DBManager
 
- 
isAutoBackupsEnabledpublic boolean isAutoBackupsEnabled()
- 
setAutoBackupsEnabledpublic void setAutoBackupsEnabled(boolean autoBackupsEnabled) - Specified by:
- setAutoBackupsEnabledin interface- DBManager
 
- 
getAutoBackupDelaypublic int getAutoBackupDelay()
- 
setAutoBackupDelaypublic void setAutoBackupDelay(int autoBackupDelay) - Specified by:
- setAutoBackupDelayin interface- DBManager
 
- 
setDefragDelaypublic void setDefragDelay(int defragDelayMin) - Specified by:
- setDefragDelayin interface- DBManager
 
- 
getFlavor
- 
getDriverDescription copied from interface:DBManagerReturns the driver for the DBManager. Important: the driver holds a session, so a new instance should be created each time.
- 
createTable- Specified by:
- createTablein interface- DBManager
 
- 
createpublic static SQLiteDBManager create(GatewayContext context, File dbDir, String filename) throws IllegalArgumentException - Throws:
- IllegalArgumentException
 
 
-