Class SQLiteDBManager
- java.lang.Object
- 
- com.inductiveautomation.ignition.gateway.localdb.sqlite.SQLiteDBManager
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected intautoBackupCountNumber of auto-backups to keep, if autoBackupsEnabled is trueprotected intautoBackupDelayDelay, in minutes, between checking if an auto-backup is necessary.protected java.io.FileautoBackupDirprotected booleanautoBackupsEnabledWhether or not to use any autobackups.protected GatewayContextcontextprotected CountingDataSourcedatasourceWhen 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 java.io.FiledbDirThe home directory that the database lives inprotected java.lang.StringdbNameThe name of the databaseprotected intdefragDelayDelay, in minutes, between defragmentation.static java.lang.StringDRIVER_CLASSprotected intfaultCountNumber of faulted copies to keepprotected LoggerExlogprotected booleannewDatabaseFlag that will be set true when this manager was started up with no database and created an initial one on connect()
 - 
Constructor SummaryConstructors Constructor Description SQLiteDBManager(GatewayContext context, java.io.File dbDir, java.lang.String dbName)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilebackupDatabase(java.io.File targetFolder, java.lang.String baseFilename)Creates a single-file backup of the internal db in the specified folder.TablecreateTable()protected java.lang.Stringdesc()intgetAutoBackupCount()intgetAutoBackupDelay()java.io.FilegetAutoBackupDir()longgetDatabaseSize()Calculates the harddrive footprint of the files that make up this sqlite instance.javax.sql.DataSourcegetDataSource()SDrivergetDriver()Returns the driver for the DBManager.intgetFaultCount()InternalDBFlavorgetFlavor()voidinitDriver()booleanisAutoBackupsEnabled()booleanisNewDatabase()booleanisRunning()protected voidonConnected(javax.sql.DataSource datasource)Called after we have been successfully connected to a sqlite database.protected voidonCreateInitial(java.sql.Statement stmt)Called on creation of a new database, after the password has been set.protected voidonShutdown()voidrestoreFromDBBackup(java.io.File dbFile)Deletes the database files and restores the provided db filevoidsetAutoBackupCount(int autoBackupCount)voidsetAutoBackupDelay(int autoBackupDelay)voidsetAutoBackupDir(java.io.File autoBackupDir)voidsetAutoBackupsEnabled(boolean autoBackupsEnabled)voidsetDefragDelay(int defragDelayMin)voidsetFaultCount(int faultCount)voidshutdown()voidshutdown(boolean compact)voidstartup()
 
- 
- 
- 
Field Detail- 
DRIVER_CLASSpublic static final java.lang.String DRIVER_CLASS - See Also:
- Constant Field Values
 
 - 
contextprotected GatewayContext context 
 - 
dbDirprotected java.io.File dbDir The home directory that the database lives in
 - 
autoBackupDirprotected java.io.File autoBackupDir 
 - 
dbNameprotected java.lang.String dbName The name of the database
 - 
faultCountprotected int faultCount Number of faulted copies to keep
 - 
autoBackupCountprotected int autoBackupCount Number of auto-backups to keep, if autoBackupsEnabled is true
 - 
autoBackupDelayprotected int autoBackupDelay Delay, in minutes, between checking if an auto-backup is necessary.
 - 
defragDelayprotected int defragDelay Delay, in minutes, between defragmentation. If 0, defrag checkpoints will not be executed. *
 - 
autoBackupsEnabledprotected 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.
 - 
datasourceprotected 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
 - 
newDatabaseprotected boolean newDatabase Flag that will be set true when this manager was started up with no database and created an initial one on connect()
 - 
logprotected LoggerEx log 
 
- 
 - 
Constructor Detail- 
SQLiteDBManagerpublic SQLiteDBManager(GatewayContext context, java.io.File dbDir, java.lang.String dbName) 
 
- 
 - 
Method Detail- 
initDriverpublic void initDriver() throws DBStartupException- Throws:
- DBStartupException
 
 - 
startuppublic void startup() throws DBStartupException- Specified by:
- startupin interface- DBManager
- Throws:
- DBStartupException
 
 - 
getDataSourcepublic javax.sql.DataSource getDataSource() - Specified by:
- getDataSourcein interface- DBManager
 
 - 
onCreateInitialprotected void onCreateInitial(java.sql.Statement stmt) throws java.sql.SQLExceptionCalled on creation of a new database, after the password has been set.- Throws:
- java.sql.SQLException
 
 - 
onConnectedprotected void onConnected(javax.sql.DataSource datasource) throws java.sql.SQLExceptionCalled after we have been successfully connected to a sqlite database.- Throws:
- java.sql.SQLException
 
 - 
onShutdownprotected void onShutdown() 
 - 
descprotected java.lang.String desc() 
 - 
restoreFromDBBackuppublic void restoreFromDBBackup(java.io.File dbFile) throws java.io.IOExceptionDeletes the database files and restores the provided db file- Specified by:
- restoreFromDBBackupin interface- DBManager
- Throws:
- java.io.IOException
 
 - 
backupDatabasepublic java.io.File backupDatabase(java.io.File targetFolder, java.lang.String baseFilename) throws java.io.IOExceptionDescription 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:
- java.io.IOException
 
 - 
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
 
 - 
getAutoBackupDirpublic java.io.File getAutoBackupDir() 
 - 
setAutoBackupDirpublic void setAutoBackupDir(java.io.File autoBackupDir) 
 - 
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
 
 - 
getFlavorpublic InternalDBFlavor getFlavor() 
 - 
getDriverpublic SDriver getDriver() Description copied from interface:DBManagerReturns the driver for the DBManager. Important: the driver holds a session, so a new instance should be created each time.
 - 
createTablepublic Table createTable() - Specified by:
- createTablein interface- DBManager
 
 
- 
 
-