public class DatabaseConnection
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.sql.Connection |
connection |
Constructor and Description |
---|
DatabaseConnection(java.lang.String databasePath)
Establishes a connection to the database at the given path.
|
Modifier and Type | Method and Description |
---|---|
EncryptedPreparedStatement |
createEncryptedPreparedStatement(java.lang.String statement)
Creates an encrypted prepared statement.
|
java.sql.PreparedStatement |
createPreparedStatement(java.lang.String statement)
Creates a prepared statement
|
java.sql.PreparedStatement |
createPreparedStatementWithGeneratedKeys(java.lang.String statement)
Creates a prepared statement that returns the keys generated after the statement is executed
(ex: after inserting a Shop, returns the ID of the newly-inserted shop)
|
void |
empty()
Empty all the tables of the connected database
|
java.sql.ResultSet |
executeQuery(java.lang.String query)
Executes the SQL query and returns the ResultSet.
|
public DatabaseConnection(java.lang.String databasePath) throws DatabaseConnectionException
databasePath
- the path to the database fileDatabaseConnectionException
public void empty() throws java.sql.SQLException
java.sql.SQLException
public java.sql.ResultSet executeQuery(java.lang.String query) throws java.sql.SQLException
query
- java.sql.SQLException
public java.sql.PreparedStatement createPreparedStatement(java.lang.String statement) throws java.sql.SQLException
statement
- java.sql.SQLException
public java.sql.PreparedStatement createPreparedStatementWithGeneratedKeys(java.lang.String statement) throws java.sql.SQLException
statement
- java.sql.SQLException
public EncryptedPreparedStatement createEncryptedPreparedStatement(java.lang.String statement) throws java.sql.SQLException
statement
- java.sql.SQLException