Class Database

java.lang.Object
com.booksaw.betterTeams.database.api.Database
Direct Known Subclasses:
BetterTeamsDatabase

public class Database extends Object
API Class to managing databases
Author:
booksaw
  • Constructor Details

    • Database

      public Database()
  • Method Details

    • setupConnectionFromConfiguration

      public void setupConnectionFromConfiguration(org.bukkit.configuration.ConfigurationSection section)
      Used to setup a connection from the provided data
      Parameters:
      section - The configuration section which contains the database information
    • setupConnection

      public void setupConnection()
      Used to setup a connection from the provided data
    • closeConnection

      public void closeConnection()
      Used to close the connection to the database
    • hasColumn

      public boolean hasColumn(TableName table, String column)
      Checks if a column exists in the specified table.
      Parameters:
      table - The table to check.
      column - The column to check for.
      Returns:
      True if the column exists, false otherwise.
    • addColumn

      protected void addColumn(TableName table, String newColumnName, String columnDefinition, String referenceColumn, boolean after)
    • addColumn

      protected void addColumn(TableName table, String newColumnName, String columnDefinition)
    • executeStatement

      public void executeStatement(String statement, String... placeholders)
      Used to execute an SQL statement
      Parameters:
      statement - The SQL statement to execute
      placeholders - The placeholders for the statement
    • executeQuery

      public PreparedStatement executeQuery(String query, String... placeholders)
      Used to execute an sql query
      Parameters:
      query - The query to execute
      placeholders - The placeholders within that query
      Returns:
      The results of the query
    • createTableIfNotExists

      public void createTableIfNotExists(TableName tableName, String tableInfo)
      Used to create a table if the table does not currently exist
      Parameters:
      tableName - The name of the table
      tableInfo - The column information about the table