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
FieldsFields inherited from class generalDatabase.DBSystem
keywords2003 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbrowseDatabases(Component parent) browseDatabasesFX(int type) FX methods to browse for an sqlite file.booleanbooleanfind out if it's possible to open the current databse with a host application (e.g.booleancheckDatabaseExists(String dbName) voidcloseConnection(PamConnection connection) Close the database connectionprotected static voidconfigureFileChooser(javafx.stage.FileChooser fileChooser) Set parameters for the file chooser.booleancreate()Create a new databaseprotected booleancreateNewDatabase(String forcedName) createNewDatabase(String newDB, Component parent, boolean askFirst) Create a new empty database file.createPamCursor(EmptyTableDefinition tableDefinition) booleanexists()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.longGet 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.booleanbooleanOpen the database with it's host application if available (e.g.booleanrestoreSettings(PamControlledUnitSettings pamControlledUnitSettings) voidsetDatabaseName(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, reOpenConnection
-
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:
browseDatabasesin 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:DBSystemCreate a new databaseThe underlying DBSystem will be responsible for any dialogs to chose database names, etc.
-
createPamCursor
- Specified by:
createPamCursorin classDBSystem
-
exists
public boolean exists() -
getConnection
Description copied from class:DBSystemOpen new database connection with a specific name- Specified by:
getConnectionin classDBSystem- Parameters:
dbName-- Returns:
-
closeConnection
Description copied from class:DBSystemClose the database connection- Overrides:
closeConnectionin classDBSystem- Parameters:
connection-
-
hasDriver
public boolean hasDriver() -
checkDatabaseExists
- Overrides:
checkDatabaseExistsin classDBSystem
-
getDatabaseName
- Specified by:
getDatabaseNamein classDBSystem- Returns:
- the name of the currently open database.
-
getShortDatabaseName
Description copied from class:DBSystemGet a shorter version of the currently open database name (e.g. without the file path name)- Overrides:
getShortDatabaseNamein classDBSystem- Returns:
- a shorter name
-
getDialogPanel
Description copied from class:DBSystemGet a database specific dialog panel to include in the database select dialog.- Specified by:
getDialogPanelin classDBSystem- Parameters:
parent- parent component- Returns:
- dialog panel
-
getSqlTypes
Description copied from class:DBSystemGet the SQLTypes object which can be used to preform system specific formatting of SQL strings.- Specified by:
getSqlTypesin classDBSystem- Returns:
-
getSystemName
- Specified by:
getSystemNamein classDBSystem- Returns:
- The name of the database system
-
getUnitName
- Specified by:
getUnitNamein interfaceSettingsNameProvider- Returns:
- A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
-
getUnitType
- Specified by:
getUnitTypein interfacePamSettings- Returns:
- A Name specific to the type, e.g. Click detector
-
getSettingsReference
- Specified by:
getSettingsReferencein interfacePamSettings- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersionin interfacePamSettings- Returns:
- An integer version number for the settings
-
restoreSettings
- Specified by:
restoreSettingsin interfacePamSettings- Parameters:
pamControlledUnitSettings-- 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:DBSystemGet 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:
getKeywordsin classDBSystem- Returns:
- list of restricted keywords.
-
canOpenDatabase
public boolean canOpenDatabase()Description copied from class:DBSystemfind out if it's possible to open the current databse with a host application (e.g. MS Access).- Overrides:
canOpenDatabasein classDBSystem- Returns:
- true if it's possible.
-
openCurrentDatabase
public boolean openCurrentDatabase()Description copied from class:DBSystemOpen the database with it's host application if available (e.g. open MS access database with Access).- Overrides:
openCurrentDatabasein classDBSystem- Returns:
- true if opened sucessfully.
-
browseDatabasesFX
FX methods to browse for an sqlite file.- Specified by:
browseDatabasesFXin classDBSystem- Parameters:
type-- Returns:
-
configureFileChooser
protected static void configureFileChooser(javafx.stage.FileChooser fileChooser) Set parameters for the file chooser.- Parameters:
fileChooser- - filechooser to configure.
-
getDialogPaneFX
Description copied from class:DBSystemGet the FX pane for the database system- Specified by:
getDialogPaneFXin classDBSystem- Returns:
- the FX settings pane for the database system.
-
createNewDatabase
- Specified by:
createNewDatabasein classDBSystem
-