Class MySQLManager


  • public class MySQLManager
    extends java.lang.Object
    A Utilities class to handle MySQL connections
    • Constructor Summary

      Constructors 
      Constructor Description
      MySQLManager​(org.bukkit.plugin.Plugin plugin, java.lang.String host, java.lang.String port, java.lang.String database, java.lang.String username, java.lang.String password)
      Instantiates a new My sql manager.
    • Method Summary

      Modifier and Type Method Description
      void addColumn​(java.lang.String table, Column column)
      Alter the table to add a column
      void addColumns​(java.lang.String table, java.util.UUID uuid, java.util.Map<java.lang.String,​java.lang.Object> set)
      Add multiple columns to the table at a single time
      java.lang.Object get​(java.lang.String table, java.lang.String column, java.util.UUID uuid)
      Get a value from the table
      java.util.TreeMap<java.util.UUID,​java.lang.Integer> getTop​(java.lang.String table, java.lang.String column, int positions)
      Get the top UUID's with values from the table
      boolean isInTable​(java.lang.String table, java.util.UUID uuid)
      Check if a UUID is in a table
      void loadTable​(java.lang.String table, Column... columns)
      Create the table if it doesn't exist
      void set​(java.lang.String table, java.lang.String column, java.util.UUID uuid, java.lang.Object value)
      Put a value into the table using the uuid as a key
      void setDebug​(boolean debug)
      Set if MySQL should debug or not
      void unload()
      Close the connection
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MySQLManager

        public MySQLManager​(org.bukkit.plugin.Plugin plugin,
                            java.lang.String host,
                            java.lang.String port,
                            java.lang.String database,
                            java.lang.String username,
                            java.lang.String password)
        Instantiates a new My sql manager.
        Parameters:
        plugin - the plugin
        host - the host
        port - the port
        database - the database
        username - the username
        password - the password
    • Method Detail

      • setDebug

        public void setDebug​(boolean debug)
        Set if MySQL should debug or not
        Parameters:
        debug - the debug
      • unload

        public void unload()
        Close the connection
      • loadTable

        public void loadTable​(java.lang.String table,
                              Column... columns)
                       throws java.sql.SQLException
        Create the table if it doesn't exist
        Parameters:
        table - the table
        columns - the columns
        Throws:
        java.sql.SQLException - the sql exception
      • getTop

        public java.util.TreeMap<java.util.UUID,​java.lang.Integer> getTop​(java.lang.String table,
                                                                                java.lang.String column,
                                                                                int positions)
        Get the top UUID's with values from the table
        Parameters:
        table - the table
        column - the column
        positions - the positions
        Returns:
        top
      • get

        public java.lang.Object get​(java.lang.String table,
                                    java.lang.String column,
                                    java.util.UUID uuid)
        Get a value from the table
        Parameters:
        table - the table
        column - the column
        uuid - the uuid
        Returns:
        object
      • isInTable

        public boolean isInTable​(java.lang.String table,
                                 java.util.UUID uuid)
        Check if a UUID is in a table
        Parameters:
        table - the table
        uuid - the uuid
        Returns:
        boolean
      • set

        public void set​(java.lang.String table,
                        java.lang.String column,
                        java.util.UUID uuid,
                        java.lang.Object value)
        Put a value into the table using the uuid as a key
        Parameters:
        table - the table
        column - the column
        uuid - the uuid
        value - the value
      • addColumns

        public void addColumns​(java.lang.String table,
                               java.util.UUID uuid,
                               java.util.Map<java.lang.String,​java.lang.Object> set)
        Add multiple columns to the table at a single time
        Parameters:
        table - the table
        uuid - the uuid
        set - the set
      • addColumn

        public void addColumn​(java.lang.String table,
                              Column column)
        Alter the table to add a column
        Parameters:
        table - the table
        column - the column