Class MariaDBStore
- Author:
- gmt2001
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoidCreates a new tablevoidAddFile(Connection connection, String fName) booleanTests if the connection to the database succeedsbooleanFileExists(String fName) Indicates if the given table already existsbooleanFileExists(Connection connection, String fName) String[]GetCategoryList(String fName) Returns a list of all values in thesectioncolumn within the tableString[]Returns a list of tables in the database.GetKeyByValue(String fName, String section, String value) Returns the value of thevariablecolumn for the given table, section, and valueString[]GetKeyList(String fName, String section) Returns a list of all values in thevariablecolumn within the table and sectionString[]GetKeysByLikeKeys(String fName, String section, String search) Returns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phraseString[]GetKeysByLikeKeysOrder(String fName, String section, String search, String order, String limit, String offset) Returns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturallyString[]GetKeysByLikeValues(String fName, String section, String search) Returns a list of values in thevariablecolumn within the table and section, where the value of thevaluecolumn contains the search phraseString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally as integersString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integersString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturallyString[]Returns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumnKeyValue[]GetKeyValueList(String fName, String section) Returns a list of allvariable/valuepairs within the table and sectionReturns the value of thevaluecolumn for the given table, section, and key as a stringbooleanIndicates if the given table contains a row matching the given section and keyvoidIncreaseBatchString(String fName, String section, String[] keys, String value) Increases the value of thevaluecolumn as an integer for all keys of the given table and sectionstatic MariaDBStoreinstance()static MariaDBStoreExecutes an SQL queryvoidRemoveFile(String fName) Deletes the tablevoidDeletes the row that matches the given table, section, and keyvoidRemoveSection(String fName, String section) Deletes all rows that match the given table and sectionvoidRenameFile(String fNameSource, String fNameDest) Renames the tablevoidSetBatchString(String fName, String section, String[] keys, String[] values) Performs a bulkDataStore.SetString(String, String, String, String)operation, using available database features to do so more efficiently.voidSets the value of thevaluecolumn for the given table, section, and key as a stringMethods inherited from class com.gmt2001.datastore.DataStore
backupDB, canBackup, CreateIndexes, decr, decr, decrD, decrD, decrF, decrF, decrL, decrL, del, dispose, DropIndexes, dsl, executeSql, exists, field, findTable, get, GetBoolean, GetBoolean, GetDouble, GetDouble, GetFloat, GetFloat, GetInteger, GetInteger, GetKeysByLikeKeysOrder, GetKeysByLikeKeysOrder, GetKeysByLikeKeysOrder, GetKeysByNumberOrder, GetKeysByNumberOrder, GetKeysByNumberOrder, GetKeysByNumberOrderValue, GetKeysByNumberOrderValue, GetKeysByNumberOrderValue, GetKeysByOrder, GetKeysByOrder, GetKeysByOrder, GetKeysByOrderValue, GetKeysByOrderValue, GetKeysByOrderValue, GetLong, GetLong, GetString, incr, incr, incrD, incrD, incrF, incrF, incrL, incrL, InsertString, OptBoolean, OptDouble, OptFloat, OptInteger, OptLong, OptRecord, OptRecord, OptString, resolveClassname, SafeChangeLong, searchByKey, searchByValue, set, setbatch, SetBoolean, SetDouble, SetFloat, SetInteger, SetLong
-
Method Details
-
instance
-
instance
-
CanConnect
public boolean CanConnect()Description copied from class:DataStoreTests if the connection to the database succeeds- Overrides:
CanConnectin classDataStore- Returns:
trueon success
-
AddFile
Description copied from class:DataStoreCreates a new table -
AddFile
-
RemoveKey
Description copied from class:DataStoreDeletes the row that matches the given table, section, and keyIf
sectionis null, deletes all rows with a matching table and key, regardless of section -
RemoveSection
Description copied from class:DataStoreDeletes all rows that match the given table and section- Overrides:
RemoveSectionin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section
-
RemoveFile
Description copied from class:DataStoreDeletes the table- Overrides:
RemoveFilein classDataStore- Parameters:
fName- a table name, without thephantombot_prefix
-
RenameFile
Description copied from class:DataStoreRenames the table- Overrides:
RenameFilein classDataStore- Parameters:
fNameSource- a table name for an existing table, without thephantombot_prefixfNameDest- a new table name that does not yet exist, without thephantombot_prefix
-
FileExists
Description copied from class:DataStoreIndicates if the given table already exists- Overrides:
FileExistsin classDataStore- Parameters:
fName- a table name, without thephantombot_prefix- Returns:
trueif the table exists
-
FileExists
-
GetFileList
Description copied from class:DataStoreReturns a list of tables in the database.Only tables with the
phantombot_prefix are returned. The prefix is removed- Overrides:
GetFileListin classDataStore- Returns:
- an array of table names
-
GetCategoryList
Description copied from class:DataStoreReturns a list of all values in thesectioncolumn within the table- Overrides:
GetCategoryListin classDataStore- Parameters:
fName- a table name, without thephantombot_prefix- Returns:
- an array of sections
-
GetKeyList
Description copied from class:DataStoreReturns a list of all values in thevariablecolumn within the table and section- Overrides:
GetKeyListin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- an array of variables
-
GetKeyValueList
Description copied from class:DataStoreReturns a list of allvariable/valuepairs within the table and section- Overrides:
GetKeyValueListin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sections- Returns:
- an array of
KeyValuepairs denoting the variables and values
-
GetKeysByOrder
public String[] GetKeysByOrder(String fName, String section, String order, String limit, String offset) Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, sorted naturally- Overrides:
GetKeysByOrderin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsorder- sort order. Valid values:"ASC"(Ascending) or"DESC"(Descending)limit- the maximum number of results to return from this queryoffset- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByNumberOrder
public String[] GetKeysByNumberOrder(String fName, String section, String order, String limit, String offset) Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, sorted naturally as integers- Overrides:
GetKeysByNumberOrderin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsorder- sort order. Valid values:"ASC"(Ascending) or"DESC"(Descending)limit- the maximum number of results to return from this queryoffset- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByOrderValue
public String[] GetKeysByOrderValue(String fName, String section, String order, String limit, String offset) Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn- Overrides:
GetKeysByOrderValuein classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsorder- sort order. Valid values:"ASC"(Ascending) or"DESC"(Descending)limit- the maximum number of results to return from this queryoffset- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByNumberOrderValue
public String[] GetKeysByNumberOrderValue(String fName, String section, String order, String limit, String offset) Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, sorted naturally by thevaluecolumn as integers- Overrides:
GetKeysByNumberOrderValuein classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsorder- sort order. Valid values:"ASC"(Ascending) or"DESC"(Descending)limit- the maximum number of results to return from this queryoffset- the offset to start reading from- Returns:
- a sorted list of variables
-
GetKeysByLikeValues
Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, where the value of thevaluecolumn contains the search phrase- Overrides:
GetKeysByLikeValuesin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevaluecolumn to match against- Returns:
- a list of variables
-
GetKeysByLikeKeys
Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase- Overrides:
GetKeysByLikeKeysin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn to match against- Returns:
- a list of variables
-
GetKeysByLikeKeysOrder
public String[] GetKeysByLikeKeysOrder(String fName, String section, String search, String order, String limit, String offset) Description copied from class:DataStoreReturns a list of values in thevariablecolumn within the table and section, where the value of thevariablecolumn contains the search phrase, sorted naturally- Overrides:
GetKeysByLikeKeysOrderin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionssearch- the partial value of thevariablecolumn to match againstorder- sort order. Valid values:"ASC"(Ascending) or"DESC"(Descending)limit- the maximum number of results to return from this queryoffset- the offset to start reading from- Returns:
- a sorted list of variables
-
HasKey
Description copied from class:DataStoreIndicates if the given table contains a row matching the given section and key -
GetKeyByValue
Description copied from class:DataStoreReturns the value of thevariablecolumn for the given table, section, and value- Overrides:
GetKeyByValuein classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionsvalue- the value of thevaluecolumn- Returns:
- the variable;
nullif not found
-
GetString
Description copied from class:DataStoreReturns the value of thevaluecolumn for the given table, section, and key as a stringA return value of
nullmay denote that the table/row is not found, or that the actual stored value is SQLNULL. UseDataStore.HasKey(String, String, String)to verify if the row exists -
SetBatchString
Description copied from class:DataStorePerforms a bulkDataStore.SetString(String, String, String, String)operation, using available database features to do so more efficiently.The array index of the keys and value params are linked
- Overrides:
SetBatchStringin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionskeys- the values of thevariablecolumn to updatevalues- the new values to set thevaluecolumn to
-
SetString
Description copied from class:DataStoreSets the value of thevaluecolumn for the given table, section, and key as a string -
IncreaseBatchString
Description copied from class:DataStoreIncreases the value of thevaluecolumn as an integer for all keys of the given table and section- Overrides:
IncreaseBatchStringin classDataStore- Parameters:
fName- a table name, without thephantombot_prefixsection- a section name.""(empty string) for the default section;nullfor all sectionskeys- the values of thevariablecolumn to updatevalue- the new value to increase thevaluecolumn by
-
query
Description copied from class:DataStoreExecutes an SQL queryThe query is executed using a
PreparedStatementwith calls toPreparedStatement.setString(int, String)For example:
executeSql("SELECT * FROM foo WHERE bar = ?", ["baz"])The value
"baz"is escaped to prevent SQL injection, then inserted in place of the?This yields the final query of
SELECT * FROM foo WHERE bar = "baz"You can use
?as many times as necessary, but must provide the same number of elements in the replacements array for the replacement to workReplacements are performed in order from left to right
Exceptions from failed SQL queries are NOT returned or thrown, but are logged in the core-error log
- Overrides:
queryin classDataStore- Parameters:
sql- The query to executereplacements- Replacements forPreparedStatement.setString(int, String)- Returns:
- An List of data as strings representing the result set, if the query was a DQL statement; an empty list otherwise. The outer list represents rows; the inner array represents columns; the values of the inner list represent the value of the row-column pair at that index as a string
-