Package persistence
Class Database
java.lang.Object
persistence.Database
- All Implemented Interfaces:
Serializable
Implementation of the Game's Database class, contains SQL queries, and SQLite
connection opening and closing methods.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Closes the Database connection.void
SQL query to crate the Game.db database.SQL query to select all the records, and returns it as an ArrayList containing DBRecords.void
Opens the Database connection.void
saveRecord
(DBRecord record) SQL query to save a DBRecord to the Database.
-
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
SQL query to save a DBRecord to the Database.- Parameters:
record
- to save
-
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.
-