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

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

Detailed Description

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.

Author
KDesp73

Member Function Documentation

◆ get()

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

Returns the underlying Connection object for the SQLite database.

Returns
the Connection instance for the database connection.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.

◆ connect()

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.

Parameters
urlthe database URL in the format jdbc:sqlite://path_to_database.
usernameUnused for SQLite.
passwordUnused for SQLite.
Exceptions
SQLExceptionif the connection to the database fails.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.

◆ executeUpdate()

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.

Parameters
querythe SQL query string to execute.
Returns
the number of rows affected by the query.
Exceptions
SQLExceptionif a database access error occurs or if the query is invalid.
IllegalArgumentExceptionif the query is not an INSERT, UPDATE, or DELETE statement.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.

◆ executeQuery()

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.

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.
IllegalArgumentExceptionif the query is not a SELECT statement.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.

◆ execute()

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.

Parameters
querythe SQL DDL query string to execute.
Returns
true if the query executed successfully, false otherwise.
Exceptions
SQLExceptionif a database access error occurs or if the query is invalid.
IllegalArgumentExceptionif the query is not a CREATE, ALTER, or DROP statement.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.

◆ close()

void io.github.kdesp73.databridge.connections.SQLiteConnection.close ( ) throws SQLException

Closes the database connection, releasing any resources.

Exceptions
SQLExceptionif an error occurs while closing the connection.

Implements io.github.kdesp73.databridge.connections.DatabaseConnection.


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