Package ortus.boxlang.runtime.jdbc
Class PendingQuery
java.lang.Object
ortus.boxlang.runtime.jdbc.PendingQuery
This class represents a query and any parameters/bindings before being
executed.
After calling
execute(ConnectionManager,IBoxContext), it returns an
ExecutedQuery with a reference to this object.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPendingQuery(IBoxContext context, @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.PendingQuery(IBoxContext context, @NonNull String sql, @NonNull List<QueryParameter> parameters) Creates a new PendingQuery instance from a SQL string and a list of parameters. -
Method Summary
Modifier and TypeMethodDescription@NonNull ExecutedQueryexecute(Connection connection, IBoxContext context) Deprecated.@NonNull ExecutedQueryexecute(BoxConnection connection, IBoxContext context) Executes the PendingQuery on a givenConnectionand returns the results in anExecutedQueryinstance.@NonNull ExecutedQueryexecute(ConnectionManager connectionManager, IBoxContext context) Executes the PendingQuery using the provided ConnectionManager and returns the results in anExecutedQueryinstance.Retrieve the generated or provided-in-query-options cache key for this query.Get the datasource used to execute this query.@NonNull StringReturns the original sql for this PendingQueryReturns a list of parameter `Object` values from the `List`. @NonNull StringReturn final SQL with paramter values
-
Field Details
-
CACHE_PREFIX
Prefix for cache queries in BoxLang- See Also:
-
-
Constructor Details
-
PendingQuery
public PendingQuery(IBoxContext context, @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:
context- The context that initiated this query.sql- The SQL string to executebindings- An array or struct ofQueryParameterto use as bindings.queryOptions- QueryOptions object denoting the options for this query.
-
PendingQuery
public PendingQuery(IBoxContext context, @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:
context- The context that initiated this query.sql- The SQL string to executeparameters- A list ofQueryParameterto use as bindings.
-
-
Method Details
-
getDataSource
Get the datasource used to execute this query.- Returns:
- The datasource used to execute this query.
-
getCacheKey
Retrieve the generated or provided-in-query-options cache key for this query. -
getOriginalSql
Returns the original sql for this PendingQuery- Returns:
- The original sql string
-
getSQLWithParamValues
Return final SQL with paramter values- Returns:
-
getParameterValues
Returns a list of parameter `Object` values from the `List`. If a parameter is a list type, its values are expanded into the main list. - Returns:
- A list of parameter values as `Object`s.
-
execute
Executes the PendingQuery using the provided ConnectionManager and returns the results in anExecutedQueryinstance.- 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 aSQLExceptionoccurs, wraps it in a DatabaseException and throws.- See Also:
-
execute
Executes the PendingQuery on a givenConnectionand returns the results in anExecutedQueryinstance.- 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 aSQLExceptionoccurs, wraps it in a DatabaseException and throws.- See Also:
-
execute
Deprecated.Useexecute(BoxConnection,IBoxContext)instead.Executes the PendingQuery on a givenConnectionand returns the results in anExecutedQueryinstance.- 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 aSQLExceptionoccurs, wraps it in a DatabaseException and throws.- See Also:
-
execute(BoxConnection,IBoxContext)instead.