Package org.postgresql.core
Interface Query
-
- All Known Implementing Classes:
BatchedQuery
public interface QueryAbstraction of a generic Query, hiding the details of any protocol-version-specific data needed to execute the query efficiently.Query objects should be explicitly closed when no longer needed; if resources are allocated on the server for this query, their cleanup is triggered by closing the Query.
- Author:
- Oliver Jowett (oliver@opencloud.com)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close this query and free any server-side resources associated with it.ParameterListcreateParameterList()Create a ParameterList suitable for storing parameters associated with this Query.intgetBatchSize()Get the number of times this Query has been batched.java.lang.StringgetNativeSql()Returns SQL in native for database format.java.util.Map<java.lang.String,java.lang.Integer>getResultSetColumnNameIndexMap()Get a map that a result set can use to find the index associated to a name.SqlCommandgetSqlCommand()Returns properties of the query (sql keyword, and some other parsing info).Query[]getSubqueries()Return a list of the Query objects that make up this query.booleanisEmpty()booleanisStatementDescribed()java.lang.StringtoString(ParameterList parameters)Returns string representation of the query, substituting particular parameter values for parameter placeholders.java.lang.StringtoString(ParameterList parameters, SqlSerializationContext context)Returns string representation of the query, substituting particular parameter values for parameter placeholders.
-
-
-
Method Detail
-
createParameterList
ParameterList createParameterList()
Create a ParameterList suitable for storing parameters associated with this Query.If this query has no parameters, a ParameterList will be returned, but it may be a shared immutable object. If this query does have parameters, the returned ParameterList is a new list, unshared by other callers.
- Returns:
- a suitable ParameterList instance for this query
-
toString
java.lang.String toString(ParameterList parameters)
Returns string representation of the query, substituting particular parameter values for parameter placeholders.Note: the method replaces the values on a best-effort basis as it might omit the replacements for parameters that can't be processed several times. For instance,
InputStreamcan be processed only once.- Parameters:
parameters- a ParameterList returned by this Query'screateParameterList()method, ornullto leave the parameter placeholders unsubstituted.- Returns:
- string representation of this query
-
toString
java.lang.String toString(ParameterList parameters, SqlSerializationContext context)
Returns string representation of the query, substituting particular parameter values for parameter placeholders.- Parameters:
parameters- a ParameterList returned by this Query'screateParameterList()method, ornullto leave the parameter placeholders unsubstituted.context- specifies configuration for converting the parameters to string- Returns:
- string representation of this query
-
getNativeSql
java.lang.String getNativeSql()
Returns SQL in native for database format.- Returns:
- SQL in native for database format
-
getSqlCommand
SqlCommand getSqlCommand()
Returns properties of the query (sql keyword, and some other parsing info).- Returns:
- returns properties of the query (sql keyword, and some other parsing info) or null if not applicable
-
close
void close()
Close this query and free any server-side resources associated with it. The resources may not be immediately deallocated, but closing a Query may make the deallocation more prompt.A closed Query should not be executed.
-
isStatementDescribed
boolean isStatementDescribed()
-
isEmpty
boolean isEmpty()
-
getBatchSize
int getBatchSize()
Get the number of times this Query has been batched.- Returns:
- number of times
addBatch()has been called.
-
getResultSetColumnNameIndexMap
java.util.Map<java.lang.String,java.lang.Integer> getResultSetColumnNameIndexMap()
Get a map that a result set can use to find the index associated to a name.- Returns:
- null if the query implementation does not support this method.
-
getSubqueries
Query[] getSubqueries()
Return a list of the Query objects that make up this query. If this object is already a SimpleQuery, returns null (avoids an extra array construction in the common case).- Returns:
- an array of single-statement queries, or
nullif this object is already a single-statement query.
-
-