Package net.lapismc.datastore
Class MySQL
- java.lang.Object
-
- net.lapismc.datastore.DataStore
-
- net.lapismc.datastore.MySQL
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.lapismc.datastore.DataStore
DataStore.StorageType
-
-
Field Summary
-
Fields inherited from class net.lapismc.datastore.DataStore
valueSeparator
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddData(Table table, java.lang.String values)Add data to a table, this may result in duplicate valuesvoidaddData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String values)Add or update data in a table, if used properly this will ensure that there are no duplicate rows and allows mass value updatingvoidcloseConnection()Closes any currently open connections to the databasevoidcreateDatabase()abstract voidcreateTables(java.sql.Connection conn)protected voiddropTable(Table table)Drop an entire tablejava.lang.BooleangetBoolean(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Booleanjava.util.List<java.lang.String>getEntireColumn(Table table, java.lang.String key)Get all the values in a column of a tablejava.util.List<java.lang.String>getEntireRow(Table table, java.lang.String primaryKey, java.lang.String value)Returns a list of String that contains all the values in a row that matches the primary key and valuejava.util.List<java.lang.String>getEntireTable(Table table)Get a list of all rows in a table, the values are separated withDataStore.valueSeparatorjava.lang.LonggetLong(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Longjava.util.List<java.lang.Long>getLongList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a list of long, use a non unique primary key and value to get multiple values returnedjava.lang.ObjectgetObject(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type ObjectDataStore.StorageTypegetStorageType()Get the storage typejava.lang.StringgetString(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a value of the type Stringjava.util.List<java.lang.String>getStringList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)Get a list of strings, use a non unique primary key and value to get multiple values returnedvoidinitialiseDataStore()This will create and necessary files and generate tablesvoidremoveAllData(Table table)Removes all rows from the given tablevoidremoveData(Table table, java.lang.String key, java.lang.String value)Removes any row with value in the key column in tablevoidsetData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String key, java.lang.String value)Set a single value in a rowvoidshutdown()Shutdown will close any connections and shutdown the connection manager-
Methods inherited from class net.lapismc.datastore.DataStore
convertData, isAsync, setAsync
-
-
-
-
Constructor Detail
-
MySQL
public MySQL(net.lapismc.lapiscore.LapisCorePlugin core, LapisURL url, java.lang.String username, java.lang.String password)
-
-
Method Detail
-
initialiseDataStore
public void initialiseDataStore()
Description copied from class:DataStoreThis will create and necessary files and generate tables- Specified by:
initialiseDataStorein classDataStore
-
getStorageType
public DataStore.StorageType getStorageType()
Description copied from class:DataStoreGet the storage type- Specified by:
getStorageTypein classDataStore- Returns:
- Returns the type of this DataStore
-
closeConnection
public void closeConnection()
Description copied from class:DataStoreCloses any currently open connections to the database- Specified by:
closeConnectionin classDataStore
-
shutdown
public void shutdown()
Description copied from class:DataStoreShutdown will close any connections and shutdown the connection manager
-
createDatabase
public void createDatabase()
-
addData
public void addData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String values)
Description copied from class:DataStoreAdd or update data in a table, if used properly this will ensure that there are no duplicate rows and allows mass value updating- Specified by:
addDatain classDataStore- Parameters:
table- The table you wish to editprimaryKey- The primary key of this tableprimaryValue- The value you wish to add/edit for in the primary key columnvalues- The values you wish to add, must be in the correct order based on the table definition and be separated by theDataStore.valueSeparator, Must include all values of the table
-
addData
public void addData(Table table, java.lang.String values)
Description copied from class:DataStoreAdd data to a table, this may result in duplicate values- Specified by:
addDatain classDataStore- Parameters:
table- The table you wish to add toovalues- The values you wish to add, must be in the correct order based on the table definition and be separated by theDataStore.valueSeparator, Must include all values of the table
-
setData
public void setData(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String key, java.lang.String value)
Description copied from class:DataStoreSet a single value in a row- Specified by:
setDatain classDataStore- Parameters:
table- The table you wish to editprimaryKey- The primary key of the row you wish to editprimaryValue- The primary keys value for the row you wish to editkey- The key of the value you wish to editvalue- The value you wish the key to be set too
-
getLong
public java.lang.Long getLong(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a value of the type Long- Specified by:
getLongin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a long if the data is found or Null if not
-
getString
public java.lang.String getString(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a value of the type String- Specified by:
getStringin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a string if the data is found or Null if not
-
getBoolean
public java.lang.Boolean getBoolean(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a value of the type Boolean- Specified by:
getBooleanin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a boolean if the data is found or Null if not
-
getObject
public java.lang.Object getObject(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a value of the type Object- Specified by:
getObjectin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns an object if the data is found or Null if not
-
getLongList
public java.util.List<java.lang.Long> getLongList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a list of long, use a non unique primary key and value to get multiple values returned- Specified by:
getLongListin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a list of long if the data is found or Null if not
-
getStringList
public java.util.List<java.lang.String> getStringList(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
Description copied from class:DataStoreGet a list of strings, use a non unique primary key and value to get multiple values returned- Specified by:
getStringListin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary key of the row you wish to accessvalue- The value of the primary key in the row you wish to accesskey- The key to the value you wish to access- Returns:
- Returns a list of string if the data is found or Null if not
-
getEntireColumn
public java.util.List<java.lang.String> getEntireColumn(Table table, java.lang.String key)
Description copied from class:DataStoreGet all the values in a column of a table- Specified by:
getEntireColumnin classDataStore- Parameters:
table- The table you wish to accesskey- The column you wish to receive values from- Returns:
- Returns a list of string of all the values in the column
-
getEntireRow
public java.util.List<java.lang.String> getEntireRow(Table table, java.lang.String primaryKey, java.lang.String value)
Description copied from class:DataStoreReturns a list of String that contains all the values in a row that matches the primary key and value- Specified by:
getEntireRowin classDataStore- Parameters:
table- The table you wish to accessprimaryKey- The primary value of the row you wish to accessvalue- The value of the primary key in the row you wish to access- Returns:
- Returns the first row that matches the criteria, an empty list if no row is found
-
removeData
public void removeData(Table table, java.lang.String key, java.lang.String value)
Description copied from class:DataStoreRemoves any row with value in the key column in table- Specified by:
removeDatain classDataStore- Parameters:
table- The table you wish to editkey- The key you wish to test forvalue- The value required for a record to be deleted
-
removeAllData
public void removeAllData(Table table)
Description copied from class:DataStoreRemoves all rows from the given table- Specified by:
removeAllDatain classDataStore- Parameters:
table- the table to truncate
-
dropTable
protected void dropTable(Table table)
Description copied from class:DataStoreDrop an entire table
-
getEntireTable
public java.util.List<java.lang.String> getEntireTable(Table table)
Description copied from class:DataStoreGet a list of all rows in a table, the values are separated withDataStore.valueSeparator- Specified by:
getEntireTablein classDataStore- Parameters:
table- The table you wish to retrieve- Returns:
- Returns a list of char separated strings containing all values in the table
-
createTables
public abstract void createTables(java.sql.Connection conn)
-
-