Package persistence

Class Database

java.lang.Object
persistence.Database
All Implemented Interfaces:
Serializable

public class Database extends Object implements Serializable
Implementation of the Game's Database class, contains SQL queries, and SQLite connection opening and closing methods.
See Also:
  • Constructor Details

    • Database

      public Database()
      Constructs the Database class. Opens a new SQLite connection, creates Game.db if it does not exist.
  • Method Details

    • createTable

      public void createTable()
      SQL query to crate the Game.db database.
    • saveRecord

      public void saveRecord(DBRecord record)
      SQL query to save a DBRecord to the Database.
      Parameters:
      record - to save
    • getRecords

      public ArrayList<DBRecord> getRecords()
      SQL query to select all the records, and returns it as an ArrayList containing DBRecords.
      Returns:
      an ArrayList containing DBRecords
    • closeConnection

      public void closeConnection()
      Closes the Database connection.
    • openConnection

      public void openConnection()
      Opens the Database connection.