DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
|
Public Member Functions | |
void | close () throws SQLException |
void | connect (String url, String username, String password) throws SQLException |
boolean | execute (String query) throws SQLException |
ResultSet | executeQuery (String query) throws SQLException |
int | executeUpdate (String query) throws SQLException |
Connection | get () |
The DatabaseConnection
interface provides methods for interacting with a relational database. It defines the contract for establishing a connection, executing SQL queries (both SELECT and DDL/DML), and closing the connection.
Implementing classes must provide the actual behavior for connecting to the database, executing queries, and managing the connection lifecycle. This interface also extends AutoCloseable
to ensure proper resource management by automatically closing the connection when no longer needed.
void io.github.kdesp73.databridge.connections.DatabaseConnection.connect | ( | String | url, |
String | username, | ||
String | password ) throws SQLException |
Establishes a connection with the database using the provided credentials.
url | the database URL, typically in the format of the driver connector followed by the path to the database (e.g., jdbc:postgresql://localhost:5432/mydb). |
username | the username for database authentication. |
password | the password for database authentication. |
SQLException | if a database access error occurs while establishing the connection. |
Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.
ResultSet io.github.kdesp73.databridge.connections.DatabaseConnection.executeQuery | ( | String | query | ) | throws SQLException |
Executes a SELECT SQL query and returns the result as a ResultSet
.
query | the SQL SELECT query string to execute. |
ResultSet
containing the result of the query. SQLException | if a database access error occurs or if the query is invalid. |
Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.
int io.github.kdesp73.databridge.connections.DatabaseConnection.executeUpdate | ( | String | query | ) | throws SQLException |
Executes an UPDATE SQL query (e.g., INSERT, UPDATE, DELETE) and returns the number of rows affected by the operation.
query | the SQL UPDATE query string to execute. |
SQLException | if a database access error occurs or if the query is invalid. |
Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.
boolean io.github.kdesp73.databridge.connections.DatabaseConnection.execute | ( | String | query | ) | throws SQLException |
Executes a DDL SQL query (e.g., CREATE, ALTER, DROP) and returns whether the execution was successful.
query | the SQL DDL query string to execute. |
true
if the DDL query executed successfully, false
otherwise. SQLException | if a database access error occurs or if the query is invalid. |
Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.
void io.github.kdesp73.databridge.connections.DatabaseConnection.close | ( | ) | throws SQLException |
Closes the database connection and releases any associated resources.
This method is automatically invoked when the connection is no longer needed, and the connection should be considered closed after this call.
SQLException | if a database access error occurs while closing the connection. |
Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.
Connection io.github.kdesp73.databridge.connections.DatabaseConnection.get | ( | ) |
Returns the plain Connection
instance that represents the underlying database connection.
Connection
object representing the database connection. Implemented in io.github.kdesp73.databridge.connections.MSAccessConnection, io.github.kdesp73.databridge.connections.OracleConnection, io.github.kdesp73.databridge.connections.PostgresConnection, and io.github.kdesp73.databridge.connections.SQLiteConnection.