DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
|
Public Member Functions | |
String | build () |
QueryBuilder | columns (String... columns) |
QueryBuilder | deleteFrom (String table) |
QueryBuilder | from (String table) |
QueryBuilder | insertInto (String table) |
QueryBuilder () | |
void | reset () |
QueryBuilder | select (String... columns) |
QueryBuilder | set (String column, Object value) |
QueryBuilder | update (String table) |
QueryBuilder | values (Object... values) |
QueryBuilder | where (String condition) |
A helper class to build SQL queries in a fluent interface style. Provides methods for constructing SQL SELECT, INSERT, UPDATE, and DELETE queries. The builder allows appending different parts of the query step-by-step.
Example usage:
QueryBuilder queryBuilder = new QueryBuilder(); String query = queryBuilder.select("id", "name") .from("users") .where("id = 1") .build();
io.github.kdesp73.databridge.helpers.QueryBuilder.QueryBuilder | ( | ) |
Initializes a new empty query builder.
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.select | ( | String... | columns | ) |
Appends the SELECT operator to the query.
columns | Columns to select. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.from | ( | String | table | ) |
Appends the FROM operator to the query.
table | Table to select from. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.where | ( | String | condition | ) |
Appends the WHERE operator to the query.
condition | SQL condition. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.insertInto | ( | String | table | ) |
Appends the INSERT INTO operator to the query.
table | Table to insert data into. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.columns | ( | String... | columns | ) |
Appends multiple columns inside parentheses for an INSERT query.
columns | Columns to add. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.values | ( | Object... | values | ) |
Appends multiple values inside parentheses for an INSERT query.
values | Values to add. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.update | ( | String | table | ) |
Appends the UPDATE operator to the query.
table | Table to perform the update on. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.set | ( | String | column, |
Object | value ) |
Appends the SET operator along with a column and a value for an UPDATE query.
column | Column name. |
value | Value for the column. |
QueryBuilder io.github.kdesp73.databridge.helpers.QueryBuilder.deleteFrom | ( | String | table | ) |
Appends the DELETE FROM operator to the query.
table | Table to delete from. |
void io.github.kdesp73.databridge.helpers.QueryBuilder.reset | ( | ) |
Resets the query builder for a new query. Clears the query and any stored columns or values.
String io.github.kdesp73.databridge.helpers.QueryBuilder.build | ( | ) |
Builds and returns the final SQL query.
IllegalStateException | If the query has not been fully constructed. |