Class BetterTeamsDatabase

java.lang.Object
com.booksaw.betterTeams.database.api.Database
com.booksaw.betterTeams.database.BetterTeamsDatabase

public class BetterTeamsDatabase extends Database
  • Constructor Details

    • BetterTeamsDatabase

      public BetterTeamsDatabase()
  • Method Details

    • setupTables

      public void setupTables()
    • select

      public PreparedStatement select(String select, TableName from)
    • selectWhere

      public PreparedStatement selectWhere(String select, TableName from, String where)
      Parameters:
      select - the element to select
      from - the table which the data is from
      where - the condition required for the data to be included
      Returns:
      the resultant resultSet
    • selectWhereOrder

      public PreparedStatement selectWhereOrder(String select, TableName from, String where, String orderBy)
      Parameters:
      select - the element to select
      from - the table which the data is from
      where - the condition required for the data to be included
      orderBy - what to order the data by
      Returns:
      the resultant resultset
    • selectOrder

      public PreparedStatement selectOrder(String select, TableName from, String orderBy)
      Parameters:
      select - the element to select
      from - the table which the data is from
      orderBy - what to order the data by
      Returns:
      The resultant resultset
    • selectInnerJoinOrder

      public PreparedStatement selectInnerJoinOrder(String select, TableName table, TableName joinTable, String columToJoin, String orderBy)
      Parameters:
      select - the element to select
      table - the table which the data is from
      joinTable - the table to join
      columToJoin - the details of the join
      orderBy - the order by conditions
      Returns:
      The resultSet of the select
    • selectInnerJoinGroupByOrder

      public PreparedStatement selectInnerJoinGroupByOrder(String select, TableName table, TableName joinTable, String columToJoin, String groupBy, String orderBy)
    • hasResult

      public boolean hasResult(TableName from, String where)
      Used to check if an SQL query has a result
      Parameters:
      from - the table which the data is from
      where - the condition required for the data to be included
      Returns:
      if the query has a result
    • getResult

      public String getResult(String column, TableName from, String where)
      Used to a specific column value from the
      Parameters:
      column - The column name
      from - the table
      where - the condition
      Returns:
      the first returned result, the specified column. Will return "" if an error occurs
    • deleteRecord

      public void deleteRecord(TableName table, String condition)
      Used to delete a record from the specified table
      Parameters:
      table - The table to update
      condition - The condition for the update
    • updateRecordWhere

      public void updateRecordWhere(TableName table, String update, String condition)
      Used to modify a record in the database
      Parameters:
      table - the table the record is in
      update - the values to update (ie "col = exp1, col2 = exp2")
      condition - The condition for which records should be updated
    • updateRecord

      public void updateRecord(TableName table, String update)
      Used to modify all records in a database
      Parameters:
      table - the table to modify
      update - the value to update (ie "col = exp1, col2 = exp2")
    • insertRecord

      public void insertRecord(TableName table, String columns, String values)
      Used to add a record into a table
      Parameters:
      table - The table to insert the record into
      columns - The columns that data is being provided for (ie "col1, col2, col3)
      values - the values to insert (ie "val1, val2, val3")
    • insertRecordIfNotExists

      public void insertRecordIfNotExists(TableName table, String columns, String values)