Class DatabaseQueryHelper
java.lang.Object
org.eclipse.dirigible.databases.helpers.DatabaseQueryHelper
public class DatabaseQueryHelper extends Object
Convenience class for common DataSource operations.
An instance represents a single DataSource.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabaseQueryHelper.ConfigThe Enum Config.static interfaceDatabaseQueryHelper.Filter<T>The Interface Filter.static interfaceDatabaseQueryHelper.RequestExecutionCallbackThe Interface RequestExecutionCallback.static interfaceDatabaseQueryHelper.ResultSetIteratorCallbackCallback interface for theexecuteQueryStatement(Connection, String, ResultSetIteratorCallback)method. -
Method Summary
Modifier and Type Method Description static voidexecuteQueryStatement(Connection connection, String sql, DatabaseQueryHelper.ResultSetIteratorCallback callback)Unlike executeSingleStatement(String, boolean, RequestIteratorCallback), this method iterates on the ResultSet and produces a table data structure in the form of a list of ordered key-value tuples.static voidexecuteSingleProcedure(Connection connection, String sql, DatabaseQueryHelper.RequestExecutionCallback callback)Executes a single SQL procedure.static voidexecuteSingleStatement(Connection connection, String sql, boolean isQuery, DatabaseQueryHelper.RequestExecutionCallback callback)Executes a single SQL statement.
-
Method Details
-
executeSingleStatement
public static void executeSingleStatement(Connection connection, String sql, boolean isQuery, DatabaseQueryHelper.RequestExecutionCallback callback)Executes a single SQL statement. The callbacks are on queryDone in case of query or updateDone in case of update, and on error. The method does not iterate on the result set and its pointer is in its initial position. It is up to the callback to do something with it.- Parameters:
connection- the connectionsql- the SQL expressionisQuery- whether it is a query or updatecallback- the callback
-
executeSingleProcedure
public static void executeSingleProcedure(Connection connection, String sql, DatabaseQueryHelper.RequestExecutionCallback callback)Executes a single SQL procedure. The callbacks are on queryDone in case of query or updateDone in case of update, and on error. The method does not iterate on the result set and its pointer is in its initial position. It is up to the callback to do something with it.- Parameters:
connection- the connectionsql- the SQL expressioncallback- the callback
-
executeQueryStatement
public static void executeQueryStatement(Connection connection, String sql, DatabaseQueryHelper.ResultSetIteratorCallback callback)Unlike executeSingleStatement(String, boolean, RequestIteratorCallback), this method iterates on the ResultSet and produces a table data structure in the form of a list of ordered key-value tuples. Schematically it looks like this:[[{column 1:value A}, {column 2: value B}, {column 3: value C}], [{column 1:value D}, {column 2: value E}, {column 3: value F}], [{column 1:value G}, {column 2: value I}, {column 3: value H}]]The callbacks are on completing the whole data structure, on error, and on each row construction.- Parameters:
connection- the connectionsql- the SQL expressioncallback- the callback
-