Class WbsDatabase

java.lang.Object
wbs.utils.util.database.WbsDatabase

public class WbsDatabase extends Object
  • Constructor Details

  • Method Details

    • addTable

      public void addTable(WbsTable table)
    • getTable

      @Nullable public @Nullable WbsTable getTable(String tableName)
    • getDatabasePath

      public String getDatabasePath()
    • getDatabaseFilePath

      public String getDatabaseFilePath()
    • databaseExists

      public boolean databaseExists()
    • createDatabase

      public boolean createDatabase()
      Create a database if it doesn't already exist under the given plugin's folder
      Returns:
      True if the database exists (regardless of if it was created or not). False if it didn't exist and failed to create.
    • createTables

      public boolean createTables()
    • select

      @NotNull public @NotNull List<WbsRecord> select(PreparedStatement query) throws WbsDatabaseException
      Runs a query directly, auto-closing the connection used and returning a list of WbsRecords from the results of the query.

      This method does not close the given statement automatically.

      Parameters:
      query - The prepared statement to run.
      Returns:
      A list of the results which may be empty. The list will also be empty if an SQL exception is thrown during the query, but the exception will not be thrown.
      Throws:
      WbsDatabaseException - If the WbsRecord was not able to be created from the ResultSet retrieved, which may occur if a field was created/retrieved without a corresponding WbsField in any table.
    • query

      @Nullable public @Nullable ResultSet query(String query)
    • queryWithoutReturns

      public boolean queryWithoutReturns(String query)
    • getField

      @Nullable public @Nullable WbsField getField(String tableName, String fieldName)
    • getConnection

      public Connection getConnection()
    • getPlugin

      public WbsPlugin getPlugin()