public class DatabaseConnection extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Connection |
connection
The actual connection.
|
protected static String |
PROPS
Path to the properties file to make the DB connection:.
|
| Constructor and Description |
|---|
DatabaseConnection()
Creates a database connection by reading the connection details
from a properties file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection and throws a runtime exception if not successful.
|
ResultSet |
execute(String sql)
Executes a simple SQL query and returns a result set.
|
PreparedStatement |
prepare(String sql)
Creates a prepared statement.
|
protected static final String PROPS
protected Connection connection
public DatabaseConnection()
throws IOException,
SQLException
IOException - Signals that an I/O exception has occurred.SQLException - the SQL exceptionpublic ResultSet execute(String sql) throws SQLException
sql - the SQL querySQLException - the SQL exceptionpublic PreparedStatement prepare(String sql) throws SQLException
sql - the SQL template for the querySQLException - the SQL exceptionpublic void close()
Copyright © 2017 Wil-Low BVBA. All rights reserved.