Class MySQL

    • Constructor Summary

      Constructors 
      Constructor Description
      MySQL​(net.lapismc.lapiscore.LapisCorePlugin core, LapisURL url, java.lang.String username, java.lang.String password)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addData​(Table table, java.lang.String values)
      Add data to a table, this may result in duplicate values
      void addData​(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 updating
      void closeConnection()
      Closes any currently open connections to the database
      void createDatabase()  
      abstract void createTables​(java.sql.Connection conn)  
      protected void dropTable​(Table table)
      Drop an entire table
      java.lang.Boolean getBoolean​(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
      Get a value of the type Boolean
      java.util.List<java.lang.String> getEntireColumn​(Table table, java.lang.String key)
      Get all the values in a column of a table
      java.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 value
      java.util.List<java.lang.String> getEntireTable​(Table table)
      Get a list of all rows in a table, the values are separated with DataStore.valueSeparator
      java.lang.Long getLong​(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
      Get a value of the type Long
      java.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 returned
      java.lang.Object getObject​(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
      Get a value of the type Object
      DataStore.StorageType getStorageType()
      Get the storage type
      java.lang.String getString​(Table table, java.lang.String primaryKey, java.lang.String value, java.lang.String key)
      Get a value of the type String
      java.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 returned
      void initialiseDataStore()
      This will create and necessary files and generate tables
      void removeAllData​(Table table)
      Removes all rows from the given table
      void removeData​(Table table, java.lang.String key, java.lang.String value)
      Removes any row with value in the key column in table
      void setData​(Table table, java.lang.String primaryKey, java.lang.String primaryValue, java.lang.String key, java.lang.String value)
      Set a single value in a row
      void shutdown()
      Shutdown will close any connections and shutdown the connection manager
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: DataStore
        This will create and necessary files and generate tables
        Specified by:
        initialiseDataStore in class DataStore
      • closeConnection

        public void closeConnection()
        Description copied from class: DataStore
        Closes any currently open connections to the database
        Specified by:
        closeConnection in class DataStore
      • shutdown

        public void shutdown()
        Description copied from class: DataStore
        Shutdown will close any connections and shutdown the connection manager
        Specified by:
        shutdown in class DataStore
      • 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: DataStore
        Add 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:
        addData in class DataStore
        Parameters:
        table - The table you wish to edit
        primaryKey - The primary key of this table
        primaryValue - The value you wish to add/edit for in the primary key column
        values - The values you wish to add, must be in the correct order based on the table definition and be separated by the DataStore.valueSeparator, Must include all values of the table
      • addData

        public void addData​(Table table,
                            java.lang.String values)
        Description copied from class: DataStore
        Add data to a table, this may result in duplicate values
        Specified by:
        addData in class DataStore
        Parameters:
        table - The table you wish to add too
        values - The values you wish to add, must be in the correct order based on the table definition and be separated by the DataStore.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: DataStore
        Set a single value in a row
        Specified by:
        setData in class DataStore
        Parameters:
        table - The table you wish to edit
        primaryKey - The primary key of the row you wish to edit
        primaryValue - The primary keys value for the row you wish to edit
        key - The key of the value you wish to edit
        value - 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: DataStore
        Get a value of the type Long
        Specified by:
        getLong in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get a value of the type String
        Specified by:
        getString in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get a value of the type Boolean
        Specified by:
        getBoolean in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get a value of the type Object
        Specified by:
        getObject in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get a list of long, use a non unique primary key and value to get multiple values returned
        Specified by:
        getLongList in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get a list of strings, use a non unique primary key and value to get multiple values returned
        Specified by:
        getStringList in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary key of the row you wish to access
        value - The value of the primary key in the row you wish to access
        key - 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: DataStore
        Get all the values in a column of a table
        Specified by:
        getEntireColumn in class DataStore
        Parameters:
        table - The table you wish to access
        key - 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: DataStore
        Returns a list of String that contains all the values in a row that matches the primary key and value
        Specified by:
        getEntireRow in class DataStore
        Parameters:
        table - The table you wish to access
        primaryKey - The primary value of the row you wish to access
        value - 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: DataStore
        Removes any row with value in the key column in table
        Specified by:
        removeData in class DataStore
        Parameters:
        table - The table you wish to edit
        key - The key you wish to test for
        value - The value required for a record to be deleted
      • removeAllData

        public void removeAllData​(Table table)
        Description copied from class: DataStore
        Removes all rows from the given table
        Specified by:
        removeAllData in class DataStore
        Parameters:
        table - the table to truncate
      • dropTable

        protected void dropTable​(Table table)
        Description copied from class: DataStore
        Drop an entire table
        Specified by:
        dropTable in class DataStore
        Parameters:
        table - The table you wish to drop
      • getEntireTable

        public java.util.List<java.lang.String> getEntireTable​(Table table)
        Description copied from class: DataStore
        Get a list of all rows in a table, the values are separated with DataStore.valueSeparator
        Specified by:
        getEntireTable in class DataStore
        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)