Class SQLTable
java.lang.Object
studio.magemonkey.codex.mccore.sql.direct.SQLTable
Represents a single table in a MySQL database.
If you close the MySQL connection, this will become invalid as it uses prepared statements from that connection. Get the tables each time you connect to the database rather than saving them.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancolumnExists(String name) Checks whether or not a column exists in the table.voidcreateColumn(String name, ColumnType type) Creates a new column in the table.createEntry(String name) Creates a new entry from the table.booleandeleteEntry(String name) Deletes an entry from the table.booleanentryExists(String name) Checks if an entry already exists<T extends ISQLEntryData>
List<T> getAllData(Class<T> c) Loads the data from the table using the data class provided.getColumnType(String name) getName()Retrieves the name of the table.Queries the MySQL table for a specific entryqueryAll()Queries the MySQL table
-
Constructor Details
-
SQLTable
Constructs a new table. This should only be called by SQLDatabase when it creates a new table or retrieves an already created one.
- Parameters:
sql- sql connectionname- name of the table
-
-
Method Details
-
getName
Retrieves the name of the table.
- Returns:
- table name
-
columnExists
Checks whether or not a column exists in the table.
- Parameters:
name- name of the column- Returns:
- true if exists, false otherwise
-
getColumnType
-
createColumn
Creates a new column in the table.
- Parameters:
name- name of the columntype- type of the column
-
query
Queries the MySQL table for a specific entry- Parameters:
name- entry name- Returns:
- query results
-
queryAll
Queries the MySQL table- Returns:
- query results
-
getAllData
Loads the data from the table using the data class provided.
This returns null an error occurred.
- Type Parameters:
T- the type of the data class- Parameters:
c- the data class to use- Returns:
- the list of loaded data
-
entryExists
Checks if an entry already exists- Parameters:
name- entry name- Returns:
- true if exists, false otherwise
-
createEntry
Creates a new entry from the table.
If the entry already exists, that will be returned instead.
- Parameters:
name- name of the entry- Returns:
- entry representation
-
deleteEntry
Deletes an entry from the table.
- Parameters:
name- entry name- Returns:
- true if successful, false otherwise
-