DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.connections.DatabaseConnection Interface Reference
Inheritance diagram for io.github.kdesp73.databridge.connections.DatabaseConnection:
AutoCloseable io.github.kdesp73.databridge.connections.MSAccessConnection io.github.kdesp73.databridge.connections.OracleConnection io.github.kdesp73.databridge.connections.PostgresConnection io.github.kdesp73.databridge.connections.SQLiteConnection

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 ()
 

Detailed Description

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.

Author
KDesp73

Member Function Documentation

◆ connect()

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.

Parameters
urlthe database URL, typically in the format of the driver connector followed by the path to the database (e.g., jdbc:postgresql://localhost:5432/mydb).
usernamethe username for database authentication.
passwordthe password for database authentication.
Exceptions
SQLExceptionif 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.

◆ executeQuery()

ResultSet io.github.kdesp73.databridge.connections.DatabaseConnection.executeQuery ( String query) throws SQLException

Executes a SELECT SQL query and returns the result as a ResultSet.

Parameters
querythe SQL SELECT query string to execute.
Returns
a ResultSet containing the result of the query.
Exceptions
SQLExceptionif 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.

◆ executeUpdate()

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.

Parameters
querythe SQL UPDATE query string to execute.
Returns
the number of rows affected by the update.
Exceptions
SQLExceptionif 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.

◆ execute()

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.

Parameters
querythe SQL DDL query string to execute.
Returns
true if the DDL query executed successfully, false otherwise.
Exceptions
SQLExceptionif 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.

◆ close()

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.

Exceptions
SQLExceptionif 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.

◆ get()

Connection io.github.kdesp73.databridge.connections.DatabaseConnection.get ( )

The documentation for this interface was generated from the following file: