Class DatabaseHelper

java.lang.Object
org.sgrewritten.stargate.util.database.DatabaseHelper

public class DatabaseHelper extends Object
  • Method Details

    • runStatement

      public static void runStatement(PreparedStatement statement) throws SQLException
      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

      public static SQLQueryGenerator getSQLGenerator(boolean usingRemoteDatabase)
      Parameters:
      usingRemoteDatabase -

      Whether the database is remote or not

      Returns:

      A new sql query generator

    • getTableNameConfiguration

      public static TableNameConfiguration getTableNameConfiguration(boolean usingRemoteDatabase)
      Parameters:
      usingRemoteDatabase -

      Whether the database is remote or not

      Returns:

      A new table name configuration