|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.lyra.Database.Interface
public class Interface
The database interface exists to implement additional functionality and to provide a certain speed increase by caching the music database.
Nested Class Summary | |
---|---|
private class |
Interface.myConnections
For some reason it is difficult to properly separate preparation and query results running without running into trouble. |
Field Summary | |
---|---|
private static java.lang.String |
CLASS
|
private java.sql.Connection |
Conn
|
private static java.lang.String |
CR
|
private static java.lang.String |
HOST
|
private static java.lang.String |
LANG
|
private Ledger |
Logger
|
private java.lang.String |
myQuery
|
private java.sql.PreparedStatement |
myUpdates
|
Constructor Summary | |
---|---|
Interface(Ledger logger)
Standard constructor for this class. |
Method Summary | |
---|---|
private boolean |
Attach(java.io.File db,
java.lang.String name)
Certain elements of the system require that other elements be attached to the primary database. |
boolean |
attachHost(java.io.File db)
Attach a new host element to the database. |
boolean |
attachLang(java.io.File db)
Attach a new language element to the database. |
boolean |
Connect(java.io.File path)
Will conduct the initial connection and logging to the SQLite database store. |
void |
debugDatabase()
When logging levels are set to CONFIG a significant amount of information will be handed to the user about the database and how it operates. |
private void |
Detach(java.lang.String name)
The DETACH command will permit the separation of a database from the main. |
void |
detachHost()
Detaches the currently connected host database from the main entry. |
void |
detachLang()
Detaches the currently connected language databases from the main entry. |
void |
Disconnect()
Will cleanly close the database connection in order to avoid any potential file locks that could be introduced otherwise. |
void |
getColumn(java.util.List<java.lang.String> list,
java.lang.String query,
java.lang.String... parameters)
An extension of the Query method. |
java.lang.Integer |
getInt(java.lang.String query,
java.lang.String... parameters)
Will return a single element if so required. |
java.sql.DatabaseMetaData |
getMetaDeta()
Direct pass through to retrieve the MetaData from the database elements themselves. |
void |
getProperties(java.util.Map<java.lang.String,java.lang.String> prop,
java.lang.String query)
Generates a Map |
java.util.Map<java.lang.String,java.lang.String> |
getRow(java.lang.String query,
java.lang.String... parameters)
This method is useful for a multiple column result. |
void |
getRows(java.util.List<java.util.Map<java.lang.String,java.lang.String>> list,
java.lang.String query,
java.lang.String... parameters)
This method is useful for a multiple column result. |
java.lang.String[][] |
getRows(java.lang.String rowQuery,
java.lang.String mainQuery,
java.lang.String... parameters)
A query which will return multiple rows must make use of this mechanism since the getColumn variant only returns a singular column with one or more rows of data. |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getSet(java.lang.String query,
java.lang.String... parameters)
A query which is meant to return a large data set back as a complex data structure containing a Map within a Map. |
java.lang.String |
getString(java.lang.String query,
java.lang.String... parameters)
Will return a single element if so required. |
Interface.myConnections |
Query(java.lang.String query,
java.lang.String... parameters)
One of the more critical components of this Class is the ability to abstract the SQL Query process. |
private void |
QueryDebug(java.lang.String method,
java.lang.String query,
java.lang.String... parameters)
Debugging capability for the query string handler. |
boolean |
updateCommence()
Rarely used method which allows for a myriad of queries to be added into a singular transaction in order to prevent out of dependency updates. |
boolean |
updateComplete()
Cleans up the update process created by multiple row updates setting up the process for another pass if necessary. |
boolean |
updateMultipleRows(java.lang.String query,
java.lang.String... parameters)
Provides the ability to update and create elements in the database while providing an audit table. |
boolean |
updateSingleRows(java.lang.String query,
java.lang.String... parameters)
Provides the ability to update and create elements in the database while providing an audit table. |
void |
Vacuum()
The VACUUM command which cleans up the database structure and can shrink up used space considerably. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Ledger Logger
private java.sql.Connection Conn
private java.sql.PreparedStatement myUpdates
private java.lang.String myQuery
private static final java.lang.String CR
private static final java.lang.String CLASS
private static final java.lang.String HOST
private static final java.lang.String LANG
Constructor Detail |
---|
public Interface(Ledger logger)
logger
- Logging capability.Method Detail |
---|
public boolean Connect(java.io.File path)
path
- File containing path to the database.
public void Disconnect()
public void debugDatabase()
The first round of information pulled from the database will be SQLite Meta Data. This can be especially useful to determine exactly what you are connected to.
getURL | The connection string used by the JDBC driver. Useful to find out if the paths are correct. |
getUserName | The user name of the database connection. Normally this will never apply to a SQLite database. |
getDatabaseProductName | Database name. This will normally always appear as SQLite |
getDatabaseProductVersion | The version of the database file which is supported. Normally 3.6.4. |
getDriverName | This should indicate SQLiteJDBC as the code only employs this driver. |
getDriverVersion | Normally you would get a version number. However with the JDBC driver used you will either get native to indicate native drivers are used or java to indicate the driver is using slower drivers for compatibility |
Information about the SQLite PRAGMA system is also included here. Some of the features may not be supported due to version issues. If that is the case the NOT SUPPORTED descriptor will be appended instead of the proper database value. The current PRAGMA types searched for are as follows:
PRAGMA auto_vacuum | Query or set the auto-vacuum status in the database. |
PRAGMA cache_size | Query or change the suggested maximum number of database disk pages that SQLite will hold in memory at once per open database file. |
PRAGMA case_sensitive_like | The default behaviour of the LIKE operator is to ignore case for ASCII characters. Hence, by default 'a' LIKE 'A' is true. |
PRAGMA count_changes | Query or change the count-changes flag. |
PRAGMA default_cache_size | This pragma queries or sets the suggested maximum number of pages of disk cache that will be allocated per open database file. |
PRAGMA empty_result_callbacks | Query or change the empty-result-callbacks flag. |
PRAGMA encoding | In first form, if the main database has already been created, then this pragma returns the text encoding used by the main database, one of "UTF-8", "UTF-16le" (little-endian UTF-16 encoding) or "UTF-16be" (big-endian UTF-16 encoding). |
PRAGMA foreign_keys | Query, set, or clear the enforcement of foreign key constraints. |
PRAGMA full_column_names | Query or change the full_column_names flag. |
PRAGMA fullfsync | Query or change the fullfsync flag. |
PRAGMA journal_mode | This pragma queries or sets the journal mode for databases associated with the current database connection. |
PRAGMA journal_size_limit | If a database connection is operating in either "exclusive mode" (PRAGMA locking_mode=exclusive) or "persistent journal mode" (PRAGMA journal_mode=persist) then under certain circumstances after committing a transaction the journal file may remain in the file-system. |
PRAGMA legacy_file_format | This pragma sets or queries the value of the legacy_file_format flag. When this flag is on, new SQLite databases are created in a file format that is readable and writable by all versions of SQLite going back to 3.0.0. When the flag is off, new databases are created using the latest file format which might not be readable or writable by versions of SQLite prior to 3.3.0. |
PRAGMA locking_mode | This pragma sets or queries the database connection locking-mode. The locking-mode is either NORMAL or EXCLUSIVE. |
PRAGMA page_size | Query or set the page size of the database. |
PRAGMA max_page_count | Query or set the maximum number of pages in the database file. |
PRAGMA read_uncommitted | Query, set, or clear READ UNCOMMITTED isolation. |
PRAGMA recursive_triggers | Query, set, or clear the recursive trigger capability. |
PRAGMA reverse_unordered_selects | When enabled, this PRAGMA causes SELECT statements without a an ORDER BY clause to emit their results in the reverse order of what they normally would. |
PRAGMA short_column_names | Query or change the short-column-names flag. |
PRAGMA synchronous | Query or change the setting of the "synchronous" flag. |
PRAGMA temp_store | Query or change the setting of the "temp_store" parameter. |
PRAGMA temp_store_directory | Query or change the setting of the "temp_store_directory" - the directory where files used for storing temporary tables and indices are kept. |
Additionally a complete list of all tables will also be displayed. This can be a great asset when determining if tables have been added or removed.
public Interface.myConnections Query(java.lang.String query, java.lang.String... parameters)
query
- A string defining the queriesparameters
- Elements of string which contain the elements
private void QueryDebug(java.lang.String method, java.lang.String query, java.lang.String... parameters)
query
- A string defining the queriesparameters
- Elements of string which contain the elementspublic java.util.Map<java.lang.String,java.lang.String> getRow(java.lang.String query, java.lang.String... parameters)
query
- String query to generate.parameters
- Array of parameters to append to the query.
public void getRows(java.util.List<java.util.Map<java.lang.String,java.lang.String>> list, java.lang.String query, java.lang.String... parameters)
list
- List containing all of the results.query
- String query to generate.parameters
- Array of parameters to append to the query.public java.lang.String[][] getRows(java.lang.String rowQuery, java.lang.String mainQuery, java.lang.String... parameters)
rowQuery
- A variant of the main query which will return a count
of rows to return.mainQuery
- The main query which will return all rows requested.parameters
- Parameters necessary to run both the Row and Main query.
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getSet(java.lang.String query, java.lang.String... parameters)
Note: The first row must be unique else the map will override.
query
- String query to generate.parameters
- Array of parameters to append to the query.
public void getColumn(java.util.List<java.lang.String> list, java.lang.String query, java.lang.String... parameters)
list
- ArrayList to populate.query
- Query to execute on the Database.parameters
- Array of strings to pass on as parameters.public java.lang.Integer getInt(java.lang.String query, java.lang.String... parameters)
query
- Query to execute on Database.parameters
- Array of strings containing parameters to pass on.
public java.lang.String getString(java.lang.String query, java.lang.String... parameters)
query
- Query to execute on Database.parameters
- Array of strings containing parameters to pass on.
public void getProperties(java.util.Map<java.lang.String,java.lang.String> prop, java.lang.String query)
prop
- Property Map to store the results.query
- Query string containing elements to run.public java.sql.DatabaseMetaData getMetaDeta() throws java.sql.SQLException
java.sql.SQLException
public boolean updateMultipleRows(java.lang.String query, java.lang.String... parameters)
query
- A string defining the queriesparameters
- Elements of string which contain the elements
public boolean updateSingleRows(java.lang.String query, java.lang.String... parameters)
query
- A string defining the queriesparameters
- Elements of string which contain the elements
private boolean Attach(java.io.File db, java.lang.String name)
db
- File element containing location of database to attach.name
- String containing the identifier to use for table lookup.
public boolean attachHost(java.io.File db)
db
- Path to the database.
public boolean attachLang(java.io.File db)
db
- Path to the database.
private void Detach(java.lang.String name)
name
- String containing name of database to detach from.public void detachHost()
public void detachLang()
public boolean updateCommence()
public boolean updateComplete()
public void Vacuum()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |