Class SQLiteConnection
java.lang.Object
ai.tutor.cab302exceptionalhandlers.model.SQLiteConnection
Defines a connection to the SQLite database.
By default, it connects to a database named "tutor.db". However, you can specify a different database name or use an in-memory database.
Usage:
* SQLiteConnection connection = new SQLiteConnection(); * // or with a specific database name * SQLiteConnection connection = new SQLiteConnection("myDatabase"); * // or for an in-memory database * SQLiteConnection connection = new SQLiteConnection(true); * * Connection conn = connection.getInstance(); *
- Author:
- Joshua M.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a connection to the default SQLite database "tutor.db".SQLiteConnection
(boolean inMemory) Creates a connection to an in-memory SQLite database or the default "tutor.db".SQLiteConnection
(String databaseName) Creates a connection to a specified SQLite database. -
Method Summary
Modifier and TypeMethodDescriptionReturns the defined instance of the SQLite database connection.
-
Constructor Details
-
SQLiteConnection
Creates a connection to the default SQLite database "tutor.db".- Throws:
SQLException
- if a database connection error occurs
-
SQLiteConnection
Creates a connection to a specified SQLite database.- Parameters:
databaseName
- the name of the database to connect to- Throws:
SQLException
- if a database connection error occurs
-
SQLiteConnection
Creates a connection to an in-memory SQLite database or the default "tutor.db".- Parameters:
inMemory
- if true, connects to an in-memory database; otherwise, connects to "tutor.db"- Throws:
SQLException
- if a database connection error occurs
-
-
Method Details
-
getInstance
Returns the defined instance of the SQLite database connection.- Returns:
- the
Connection
instance - Throws:
RuntimeException
- if the connection has not been established
-