Package generalDatabase.sqlite
Class SqliteSystem
java.lang.Object
generalDatabase.DBSystem
generalDatabase.sqlite.SqliteSystem
- All Implemented Interfaces:
PamSettings
,SettingsNameProvider
PAMGuard database system to make use of Sqlite databases: https://www.sqlite.org/
Specifically, this database system makes use of the xerial sqlite-jdbc library,
https://github.com/xerial/sqlite-jdbc.
NB: The default sqlite-jdbc from xerial does not support JDBC escape syntax, which
is used by PAMGuard to interpret timestamps in mixed and viewer modes. Until this
is addressed, sqlite database will fail in mixed and viewer mode.
- Author:
- brian_mil
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbrowseDatabases
(Component parent) browseDatabasesFX
(int type) FX methods to browse for an sqlite file.boolean
boolean
find out if it's possible to open the current databse with a host application (e.g.boolean
checkDatabaseExists
(String dbName) void
closeConnection
(PamConnection connection) Close the database connectionboolean
create()
Create a new databasecreateNewDatabase
(String newDB, Component parent, boolean askFirst) Create a new empty database file.createPamCursor
(EmptyTableDefinition tableDefinition) boolean
exists()
getConnection
(String dbName) Open new database connection with a specific nameGet the FX pane for the database systemgetDialogPanel
(Component parent) Get a database specific dialog panel to include in the database select dialog.Get a list of keywords which potentially may not be used for column names in an SQL statement.long
Get a shorter version of the currently open database name (e.g.Get the SQLTypes object which can be used to preform system specific formatting of SQL strings.boolean
boolean
Open the database with it's host application if available (e.g.boolean
restoreSettings
(PamControlledUnitSettings pamControlledUnitSettings) void
setDatabaseName
(String databaseName) Set the database name, check it exists, check it's end and add to top of list of databases.Methods inherited from class generalDatabase.DBSystem
checkDatabaseExists, getConnection
-
Field Details
-
SYSTEMNAME
- See Also:
-
-
Constructor Details
-
SqliteSystem
-
-
Method Details
-
getRecentDatabases
- Returns:
- the recentDatabases
-
setDatabaseName
Set the database name, check it exists, check it's end and add to top of list of databases.- Parameters:
databaseName
-
-
browseDatabases
- Specified by:
browseDatabases
in classDBSystem
-
createNewDatabase
Create a new empty database file.- Parameters:
newDB
- full path for database file (can be missing .sqlit3 if you like - this will get checked and added).parent
- window (for confirm dialog, can be null)askFirst
- show a confirm dialog before creating the database file.- Returns:
- a path to the file, whether created or no.
-
canCreate
public boolean canCreate() -
create
public boolean create()Description copied from class:DBSystem
Create a new databaseThe underlying DBSystem will be responsible for any dialogs to chose database names, etc.
-
createPamCursor
- Specified by:
createPamCursor
in classDBSystem
-
exists
public boolean exists() -
getConnection
Description copied from class:DBSystem
Open new database connection with a specific name- Specified by:
getConnection
in classDBSystem
- Returns:
-
closeConnection
Description copied from class:DBSystem
Close the database connection- Overrides:
closeConnection
in classDBSystem
-
hasDriver
public boolean hasDriver() -
checkDatabaseExists
- Overrides:
checkDatabaseExists
in classDBSystem
-
getDatabaseName
- Specified by:
getDatabaseName
in classDBSystem
- Returns:
- the name of the currently open database.
-
getShortDatabaseName
Description copied from class:DBSystem
Get a shorter version of the currently open database name (e.g. without the file path name)- Overrides:
getShortDatabaseName
in classDBSystem
- Returns:
- a shorter name
-
getDialogPanel
Description copied from class:DBSystem
Get a database specific dialog panel to include in the database select dialog.- Specified by:
getDialogPanel
in classDBSystem
- Parameters:
parent
- parent component- Returns:
- dialog panel
-
getSqlTypes
Description copied from class:DBSystem
Get the SQLTypes object which can be used to preform system specific formatting of SQL strings.- Specified by:
getSqlTypes
in classDBSystem
- Returns:
-
getSystemName
- Specified by:
getSystemName
in classDBSystem
- Returns:
- The name of the database system
-
getUnitName
- Specified by:
getUnitName
in interfaceSettingsNameProvider
- Returns:
- A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
-
getUnitType
- Specified by:
getUnitType
in interfacePamSettings
- Returns:
- A Name specific to the type, e.g. Click detector
-
getSettingsReference
- Specified by:
getSettingsReference
in interfacePamSettings
- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersion
in interfacePamSettings
- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettings
in interfacePamSettings
- Returns:
- true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
-
getKeywords
Description copied from class:DBSystem
Get a list of keywords which potentially may not be used for column names in an SQL statement. In reality, this list is complete overkill. Override for each system and try to reduce the list as much as possible.- Overrides:
getKeywords
in classDBSystem
- Returns:
- list of restricted keywords.
-
canOpenDatabase
public boolean canOpenDatabase()Description copied from class:DBSystem
find out if it's possible to open the current databse with a host application (e.g. MS Access).- Overrides:
canOpenDatabase
in classDBSystem
- Returns:
- true if it's possible.
-
openCurrentDatabase
public boolean openCurrentDatabase()Description copied from class:DBSystem
Open the database with it's host application if available (e.g. open MS access database with Access).- Overrides:
openCurrentDatabase
in classDBSystem
- Returns:
- true if opened sucessfully.
-
browseDatabasesFX
FX methods to browse for an sqlite file.- Specified by:
browseDatabasesFX
in classDBSystem
- Returns:
-
getDialogPaneFX
Description copied from class:DBSystem
Get the FX pane for the database system- Specified by:
getDialogPaneFX
in classDBSystem
- Returns:
- the FX settings pane for the database system.
-