Class GlobalMySQL
java.lang.Object
com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL
Abstract class for managing global MySQL database operations across multiple servers.
-
Constructor Summary
ConstructorsConstructorDescriptionGlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.config.MysqlConfig config) Constructs a GlobalMySQL instance with the specified table name and MySQL configuration.GlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.MySQL mysql) Constructs a GlobalMySQL instance with the specified table name and MySQL connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new column to the database table.voidalterColumnType(String column, String newType) Alters the type of an existing column in the database table.voidcheckColumn(String column, com.bencodez.simpleapi.sql.DataType dataType) Checks if a column exists in the table, and adds it if it does not.voidClears the basic cache and reloads columns and servers from the database.voidclose()Closes the database connection.booleancontainsKey(String server) Checks if the database contains a record for the specified server.booleancontainsKeyQuery(String index) Queries the database to check if it contains a record for the specified server.booleancontainsServer(String server) Checks if the cached server list contains the specified server.abstract voidLogs an exception for debugging purposes.abstract voidLogs a debug message.voiddeleteServer(String server) Deletes a server record from the database.voidexecuteQuery(String str) Executes a SQL query with placeholder replacement.Gets the list of column names in the table.Queries the database for the list of column names in the table.ArrayList<com.bencodez.simpleapi.sql.Column> Gets the exact record for the specified server.ArrayList<com.bencodez.simpleapi.sql.Column> getExactQuery(com.bencodez.simpleapi.sql.Column column) Queries the database for records matching the specified column.getName()Gets the table name.ArrayList<com.bencodez.simpleapi.sql.Column> Queries the database for all server records.Gets the set of server names from cache or database.Queries the database for all server names.abstract voidLogs an informational message.voidInserts a single column value for the specified server.voidinsertQuery(String index, List<com.bencodez.simpleapi.sql.Column> cols) Inserts or updates multiple column values for the specified server.booleanisIntColumn(String key) Checks if the specified column is an integer column.booleanChecks if batch updates are supported.voidloadData()Loads column and batch update support data from the database.abstract voidLogs a severe error message.voidUpdates a single column value for the specified server.voidUpdates multiple column values for the specified server.abstract voidLogs a warning message.voidwipeColumnData(String columnName) Wipes all data from the specified column by setting values to NULL.
-
Constructor Details
-
GlobalMySQL
Constructs a GlobalMySQL instance with the specified table name and MySQL connection.- Parameters:
tableName- the name of the tablemysql- the MySQL instance to use
-
GlobalMySQL
Constructs a GlobalMySQL instance with the specified table name and MySQL configuration.- Parameters:
tableName- the name of the tableconfig- the MySQL configuration
-
-
Method Details
-
addColumn
Adds a new column to the database table.- Parameters:
column- the name of the column to adddataType- the data type of the column
-
alterColumnType
Alters the type of an existing column in the database table.- Parameters:
column- the name of the column to alternewType- the new data type for the column
-
checkColumn
Checks if a column exists in the table, and adds it if it does not.- Parameters:
column- the name of the column to checkdataType- the data type of the column
-
clearCacheBasic
public void clearCacheBasic()Clears the basic cache and reloads columns and servers from the database. -
close
public void close()Closes the database connection. -
containsKey
Checks if the database contains a record for the specified server.- Parameters:
server- the server name to check- Returns:
- true if the server exists, false otherwise
-
containsKeyQuery
Queries the database to check if it contains a record for the specified server.- Parameters:
index- the server name to check- Returns:
- true if the server exists in the database, false otherwise
-
containsServer
Checks if the cached server list contains the specified server.- Parameters:
server- the server name to check- Returns:
- true if the server is in the cache, false otherwise
-
debugEx
Logs an exception for debugging purposes.- Parameters:
e- the exception to log
-
debugLog
Logs a debug message.- Parameters:
text- the message to log
-
deleteServer
Deletes a server record from the database.- Parameters:
server- the server name to delete
-
executeQuery
Executes a SQL query with placeholder replacement.- Parameters:
str- the SQL query string
-
getColumns
Gets the list of column names in the table.- Returns:
- the list of column names
-
getColumnsQueury
Queries the database for the list of column names in the table.- Returns:
- the list of column names
-
getExact
Gets the exact record for the specified server.- Parameters:
server- the server name- Returns:
- the list of columns for the server
-
getExactQuery
public ArrayList<com.bencodez.simpleapi.sql.Column> getExactQuery(com.bencodez.simpleapi.sql.Column column) Queries the database for records matching the specified column.- Parameters:
column- the column to match- Returns:
- the list of columns matching the query
-
getName
Gets the table name.- Returns:
- the table name
-
getRowsQuery
Queries the database for all server records.- Returns:
- the list of server columns
-
getServers
Gets the set of server names from cache or database.- Returns:
- the set of server names
-
getServersQuery
Queries the database for all server names.- Returns:
- the list of server names
-
info
Logs an informational message.- Parameters:
text- the message to log
-
insert
Inserts a single column value for the specified server.- Parameters:
index- the server namecolumn- the column namevalue- the value to insert
-
insertQuery
Inserts or updates multiple column values for the specified server.- Parameters:
index- the server namecols- the list of columns to insert
-
isIntColumn
Checks if the specified column is an integer column.- Parameters:
key- the column name- Returns:
- true if the column is an integer column, false otherwise
-
isUseBatchUpdates
public boolean isUseBatchUpdates()Checks if batch updates are supported.- Returns:
- true if batch updates are supported, false otherwise
-
loadData
public void loadData()Loads column and batch update support data from the database. -
logSevere
Logs a severe error message.- Parameters:
text- the message to log
-
update
Updates multiple column values for the specified server.- Parameters:
index- the server namecols- the list of columns to updaterunAsync- whether to run the update asynchronously
-
update
Updates a single column value for the specified server.- Parameters:
index- the server namecolumn- the column namevalue- the value to update
-
warning
Logs a warning message.- Parameters:
text- the message to log
-
wipeColumnData
Wipes all data from the specified column by setting values to NULL.- Parameters:
columnName- the name of the column to wipe
-