AutoCloseablepublic class DBConnection extends Object implements AutoCloseable
| Constructor | Description |
|---|---|
DBConnection() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Closes the connection to the database.
|
ResultSet |
execute(String query) |
Executes an SELECT SQL statement on the database without Java parameters.
|
ResultSet |
execute(String query,
Object... params) |
Executes an SELECT SQL statement on the database with Java parameters.
|
boolean |
isOpen() |
Determines if a connection to the database still exists or not.
|
boolean |
isValid() |
Checks if the connection is valid/successful.
|
boolean |
update(String query) |
This command is used for any queries that are supposed to update the database, such as UPDATE, DELETE, TRUNCATE etc.
|
boolean |
update(String query,
Object... params) |
This command is used for any queries that are supposed to update the database, such as UPDATE, DELETE, TRUNCATE etc.
|
public boolean isValid()
public ResultSet execute(String query)
query - The query to be executed.ResultSet containing the result from the SELECT query.public ResultSet execute(String query, Object... params)
query - The query to be executed.params - The Java parameters to be inserted into the query.ResultSet containing the result from the SELECT query.public boolean update(String query)
query - The query to be executed.true if the update was successful, false if not.public boolean update(String query, Object... params)
query - The query to be executed.params - The Java parameters to be inserted into the query.true if the update was successful, false if not.public boolean isOpen()
True if a connection exists, false if not.
This method will return false if an exception occurs.public void close()
close in interface AutoCloseableCopyright © 2018. All rights reserved.