Package me.bimmr.bimmcore.mysql
Class MySQLManager
- java.lang.Object
-
- me.bimmr.bimmcore.mysql.MySQLManager
-
public class MySQLManager extends java.lang.ObjectA 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 voidaddColumn(java.lang.String table, Column column)Alter the table to add a columnvoidaddColumns(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 timejava.lang.Objectget(java.lang.String table, java.lang.String column, java.util.UUID uuid)Get a value from the tablejava.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 tablebooleanisInTable(java.lang.String table, java.util.UUID uuid)Check if a UUID is in a tablevoidloadTable(java.lang.String table, Column... columns)Create the table if it doesn't existvoidset(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 keyvoidsetDebug(boolean debug)Set if MySQL should debug or notvoidunload()Close the connection
-
-
-
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 pluginhost- the hostport- the portdatabase- the databaseusername- the usernamepassword- 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.SQLExceptionCreate the table if it doesn't exist- Parameters:
table- the tablecolumns- 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 tablecolumn- the columnpositions- 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 tablecolumn- the columnuuid- 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 tableuuid- 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 tablecolumn- the columnuuid- the uuidvalue- 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 tableuuid- the uuidset- the set
-
addColumn
public void addColumn(java.lang.String table, Column column)Alter the table to add a column- Parameters:
table- the tablecolumn- the column
-
-