Class PendingQuery

java.lang.Object
ortus.boxlang.runtime.jdbc.PendingQuery

public class PendingQuery extends Object
This class represents a query and any parameters/bindings before being executed. After calling
invalid reference
#execute()
, it returns an ExecutedQuery with a reference to this object.
  • Constructor Details

    • PendingQuery

      public PendingQuery(@Nonnull String sql, Object bindings, QueryOptions queryOptions)
      Creates a new PendingQuery instance from a SQL string, a list of parameters, and the original SQL string.
      Parameters:
      sql - The SQL string to execute
      parameters - A list of QueryParameter to use as bindings.
      originalSql - The original sql string. This will include named parameters if the `PendingQuery` was constructed using an IStruct.
    • PendingQuery

      public PendingQuery(@Nonnull String sql, @Nonnull List<QueryParameter> parameters)
      Creates a new PendingQuery instance from a SQL string and a list of parameters. This constructor uses the provided SQL string as the original SQL.
      Parameters:
      sql - The SQL string to execute
      parameters - A list of QueryParameter to use as bindings.
  • Method Details

    • getOriginalSql

      @Nonnull public String getOriginalSql()
      Returns the original sql for this PendingQuery
      Returns:
      The original sql string
    • getParameterValues

      @Nonnull public List<Object> getParameterValues()
      Returns a list of parameter `Object` values from the `List`.
      Returns:
      A list of parameter values as `Object`s.
    • execute

      @Nonnull public ExecutedQuery execute(ConnectionManager connectionManager)
      Executes the PendingQuery using the provided ConnectionManager and returns the results in an ExecutedQuery instance.
      Parameters:
      connectionManager - The ConnectionManager instance to use for getting connections from the current context.
      Returns:
      An ExecutedQuery instance with the results of this JDBC execution, as well as a link to this PendingQuery instance.
      Throws:
      DatabaseException - If a SQLException occurs, wraps it in a DatabaseException and throws.
      See Also:
    • execute

      @Nonnull public ExecutedQuery execute(Connection connection)
      Executes the PendingQuery on a given Connection and returns the results in an ExecutedQuery instance.
      Parameters:
      connection - The Connection instance to use for executing the query. It is the responsibility of the caller to close the connection after this method returns.
      Returns:
      An ExecutedQuery instance with the results of this JDBC execution, as well as a link to this PendingQuery instance.
      Throws:
      DatabaseException - If a SQLException occurs, wraps it in a DatabaseException and throws.
      See Also: