Class DatabaseHelper
java.lang.Object
org.sgrewritten.stargate.util.database.DatabaseHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
createTables
(SQLDatabaseAPI database, SQLQueryGenerator sqlQueryGenerator, boolean useInterServerNetworks) Create all tables used by the sql databasestatic SQLQueryGenerator
getSQLGenerator
(boolean usingRemoteDatabase) static TableNameConfiguration
getTableNameConfiguration
(boolean usingRemoteDatabase) static SQLDatabaseAPI
loadDatabase
(Stargate stargate) Loads the databasestatic void
runStatement
(PreparedStatement statement) Executes and closes the given statement
-
Method Details
-
runStatement
Executes and closes the given statement- Parameters:
statement
-The statement to execute
- Throws:
SQLException
-If an SQL exception occurs
-
createTables
public static void createTables(SQLDatabaseAPI database, SQLQueryGenerator sqlQueryGenerator, boolean useInterServerNetworks) throws SQLException Create all tables used by the sql database- Parameters:
database
-SQL database
sqlQueryGenerator
-Something that generates SQL queries
useInterServerNetworks
-Whether to create tables for inter server portals
- Throws:
SQLException
-IF anything went wrong with creating the tables
-
loadDatabase
public static SQLDatabaseAPI loadDatabase(Stargate stargate) throws SQLException, StargateInitializationException Loads the database- Parameters:
stargate
-The Stargate instance to use for initialization
- Returns:
The loaded database
- Throws:
SQLException
-If an SQL exception occurs
StargateInitializationException
-
getSQLGenerator
- Parameters:
usingRemoteDatabase
-Whether the database is remote or not
- Returns:
A new sql query generator
-
getTableNameConfiguration
- Parameters:
usingRemoteDatabase
-Whether the database is remote or not
- Returns:
A new table name configuration
-