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.
  • 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 connection
      sql - the SQL expression
      isQuery - whether it is a query or update
      callback - 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 connection
      sql - the SQL expression
      callback - 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 connection
      sql - the SQL expression
      callback - the callback