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 () |
Public Member Functions inherited from io.github.kdesp73.databridge.connections.DatabaseConnection |
The SQLiteConnection
class implements the DatabaseConnection
interface for connecting to and interacting with an SQLite database.
This class provides methods to establish a connection to the SQLite database, execute SQL queries (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP), and close the connection. It also supports retrying operations on failure using the Again
helper class.
The SQLite JDBC driver must be present to use this class. The connection URL must begin with jdbc:sqlite://
or be jdbc:sqlite::memory:
for in-memory databases.
Connection io.github.kdesp73.databridge.connections.SQLiteConnection.get | ( | ) |
Returns the underlying Connection
object for the SQLite database.
Connection
instance for the database connection. Implements io.github.kdesp73.databridge.connections.DatabaseConnection.
void io.github.kdesp73.databridge.connections.SQLiteConnection.connect | ( | String | url, |
String | username, | ||
String | password ) throws SQLException |
Establishes a connection to the SQLite database.
The URL should be in the form jdbc:sqlite://path_to_database
. For in-memory databases, jdbc:sqlite::memory:
should be used. If the URL does not start with jdbc:sqlite://
, it will be prefixed automatically.
url | the database URL in the format jdbc:sqlite://path_to_database . |
username | Unused for SQLite. |
password | Unused for SQLite. |
SQLException | if the connection to the database fails. |
Implements io.github.kdesp73.databridge.connections.DatabaseConnection.
int io.github.kdesp73.databridge.connections.SQLiteConnection.executeUpdate | ( | String | query | ) | throws SQLException |
Executes an UPDATE SQL query (INSERT, UPDATE, DELETE) on the SQLite database.
The query is validated to ensure it is an INSERT, UPDATE, or DELETE statement before execution.
query | the SQL query string to execute. |
SQLException | if a database access error occurs or if the query is invalid. |
IllegalArgumentException | if the query is not an INSERT, UPDATE, or DELETE statement. |
Implements io.github.kdesp73.databridge.connections.DatabaseConnection.
ResultSet io.github.kdesp73.databridge.connections.SQLiteConnection.executeQuery | ( | String | query | ) | throws SQLException |
Executes a SELECT SQL query and returns the result as a ResultSet
.
The query is validated to ensure it is a SELECT statement before execution.
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. |
IllegalArgumentException | if the query is not a SELECT statement. |
Implements io.github.kdesp73.databridge.connections.DatabaseConnection.
boolean io.github.kdesp73.databridge.connections.SQLiteConnection.execute | ( | String | query | ) | throws SQLException |
Executes a DDL SQL query (e.g., CREATE, ALTER, DROP) on the SQLite database.
The query is validated to ensure it is a CREATE, ALTER, or DROP statement before execution.
query | the SQL DDL query string to execute. |
true
if the query executed successfully, false
otherwise. SQLException | if a database access error occurs or if the query is invalid. |
IllegalArgumentException | if the query is not a CREATE, ALTER, or DROP statement. |
Implements io.github.kdesp73.databridge.connections.DatabaseConnection.
void io.github.kdesp73.databridge.connections.SQLiteConnection.close | ( | ) | throws SQLException |
Closes the database connection, releasing any resources.
SQLException | if an error occurs while closing the connection. |
Implements io.github.kdesp73.databridge.connections.DatabaseConnection.