Modifier and Type | Field and Description |
---|---|
protected int |
autoBackupCount
Number of auto-backups to keep, if autoBackupsEnabled is true
|
protected int |
autoBackupDelay
Delay, in minutes, between checking if an auto-backup is necessary.
|
protected java.io.File |
autoBackupDir |
protected boolean |
autoBackupsEnabled
Whether or not to use any autobackups.
|
protected GatewayContext |
context |
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
|
protected java.io.File |
dbDir
The home directory that the database lives in
|
protected java.lang.String |
dbName
The name of the database
|
protected int |
defragDelay
Delay, in minutes, between defragmentation.
|
static java.lang.String |
DRIVER_CLASS |
protected int |
faultCount
Number of faulted copies to keep
|
protected LoggerEx |
log |
protected boolean |
newDatabase
Flag that will be set true when this manager was started up with no database and created an initial one on
connect()
|
Constructor and Description |
---|
SQLiteDBManager(GatewayContext context,
java.io.File dbDir,
java.lang.String dbName) |
Modifier and Type | Method and Description |
---|---|
java.io.File |
backupDatabase(java.io.File targetFolder,
java.lang.String baseFilename)
Creates a single-file backup of the internal db in the specified folder.
|
Table |
createTable() |
protected java.lang.String |
desc() |
int |
getAutoBackupCount() |
int |
getAutoBackupDelay() |
java.io.File |
getAutoBackupDir() |
long |
getDatabaseSize()
Calculates the harddrive footprint of the files that make up this sqlite instance.
|
javax.sql.DataSource |
getDataSource() |
SDriver |
getDriver()
Returns the driver for the DBManager.
|
int |
getFaultCount() |
InternalDBFlavor |
getFlavor() |
void |
initDriver() |
boolean |
isAutoBackupsEnabled() |
boolean |
isNewDatabase() |
boolean |
isRunning() |
protected void |
onConnected(javax.sql.DataSource datasource)
Called after we have been successfully connected to a sqlite database.
|
protected void |
onCreateInitial(java.sql.Statement stmt)
Called on creation of a new database, after the password has been set.
|
protected void |
onShutdown() |
void |
restoreFromDBBackup(java.io.File dbFile)
Deletes the database files and restores the provided db file
|
void |
setAutoBackupCount(int autoBackupCount) |
void |
setAutoBackupDelay(int autoBackupDelay) |
void |
setAutoBackupDir(java.io.File autoBackupDir) |
void |
setAutoBackupsEnabled(boolean autoBackupsEnabled) |
void |
setDefragDelay(int defragDelayMin) |
void |
setFaultCount(int faultCount) |
void |
shutdown() |
void |
shutdown(boolean compact) |
void |
startup() |
public static final java.lang.String DRIVER_CLASS
protected GatewayContext context
protected java.io.File dbDir
protected java.io.File autoBackupDir
protected java.lang.String dbName
protected int faultCount
protected int autoBackupCount
protected int autoBackupDelay
protected int defragDelay
protected boolean autoBackupsEnabled
protected CountingDataSource datasource
protected boolean newDatabase
protected LoggerEx log
public SQLiteDBManager(GatewayContext context, java.io.File dbDir, java.lang.String dbName)
public void initDriver() throws DBStartupException
DBStartupException
public void startup() throws DBStartupException
startup
in interface DBManager
DBStartupException
public javax.sql.DataSource getDataSource()
getDataSource
in interface DBManager
protected void onCreateInitial(java.sql.Statement stmt) throws java.sql.SQLException
java.sql.SQLException
protected void onConnected(javax.sql.DataSource datasource) throws java.sql.SQLException
java.sql.SQLException
protected void onShutdown()
protected java.lang.String desc()
public void restoreFromDBBackup(java.io.File dbFile) throws java.io.IOException
restoreFromDBBackup
in interface DBManager
java.io.IOException
public java.io.File backupDatabase(java.io.File targetFolder, java.lang.String baseFilename) throws java.io.IOException
DBManager
backupDatabase
in interface DBManager
java.io.IOException
public boolean isNewDatabase()
isNewDatabase
in interface DBManager
public void shutdown()
public long getDatabaseSize()
getDatabaseSize
in interface DBManager
public java.io.File getAutoBackupDir()
public void setAutoBackupDir(java.io.File autoBackupDir)
public int getFaultCount()
public void setFaultCount(int faultCount)
setFaultCount
in interface DBManager
public int getAutoBackupCount()
public void setAutoBackupCount(int autoBackupCount)
setAutoBackupCount
in interface DBManager
public boolean isAutoBackupsEnabled()
public void setAutoBackupsEnabled(boolean autoBackupsEnabled)
setAutoBackupsEnabled
in interface DBManager
public int getAutoBackupDelay()
public void setAutoBackupDelay(int autoBackupDelay)
setAutoBackupDelay
in interface DBManager
public void setDefragDelay(int defragDelayMin)
setDefragDelay
in interface DBManager
public InternalDBFlavor getFlavor()
public SDriver getDriver()
DBManager
public Table createTable()
createTable
in interface DBManager