public class QueryExecutorImpl extends java.lang.Object implements QueryExecutor
QUERY_BOTH_ROWS_AND_STATUS, QUERY_DESCRIBE_ONLY, QUERY_DISALLOW_BATCHING, QUERY_FORWARD_CURSOR, QUERY_NO_METADATA, QUERY_NO_RESULTS, QUERY_ONESHOT, QUERY_SUPPRESS_BEGIN| Constructor and Description |
|---|
QueryExecutorImpl(org.postgresql.core.v2.ProtocolConnectionImpl protoConnection,
PGStream pgStream,
Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
ParameterList |
createFastpathParameters(int count)
Create a new ParameterList implementation suitable for invoking a
fastpath function via
QueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean). |
Query |
createParameterizedQuery(java.lang.String sql)
Create a parameterized Query object suitable for execution by
this QueryExecutor.
|
Query |
createSimpleQuery(java.lang.String sql)
Create an unparameterized Query object suitable for execution by
this QueryExecutor.
|
void |
execute(Query[] queries,
ParameterList[] parameters,
ResultHandler handler,
int maxRows,
int fetchSize,
int flags)
Execute several Query, passing results to a provided ResultHandler.
|
void |
execute(Query query,
ParameterList parameters,
ResultHandler handler,
int maxRows,
int fetchSize,
int flags)
Execute a Query, passing results to a provided ResultHandler.
|
byte[] |
fastpathCall(int fnid,
ParameterList parameters,
boolean suppressBegin)
Invoke a backend function via the fastpath interface.
|
void |
fetch(ResultCursor cursor,
ResultHandler handler,
int rows)
Fetch additional rows from a cursor.
|
void |
processNotifies()
Prior to attempting to retrieve notifications, we need to pull
any recently received notifications off of the network buffers.
|
protected void |
processResults(Query originalQuery,
ResultHandler handler,
int maxRows,
int flags) |
protected void |
sendQuery(org.postgresql.core.v2.V2Query query,
org.postgresql.core.v2.SimpleParameterList params,
java.lang.String queryPrefix) |
CopyOperation |
startCopy(java.lang.String sql,
boolean suppressBegin)
Issues a COPY FROM STDIN / COPY TO STDOUT statement and returns
handler for associated operation.
|
public Query createSimpleQuery(java.lang.String sql)
QueryExecutorQuery.createParameterList() of the returned object will
always return an empty ParameterList.createSimpleQuery in interface QueryExecutorsql - the SQL for the query to createpublic Query createParameterizedQuery(java.lang.String sql)
QueryExecutorQuery.createParameterList() of the returned object will
create an appropriately-sized ParameterList.createParameterizedQuery in interface QueryExecutorsql - the SQL for the query to create, with '?' placeholders for
parameters.public ParameterList createFastpathParameters(int count)
QueryExecutorQueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean).createFastpathParameters in interface QueryExecutorcount - the number of parameters the fastpath call will takeQueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean).public byte[] fastpathCall(int fnid,
ParameterList parameters,
boolean suppressBegin)
throws java.sql.SQLException
QueryExecutorfastpathCall in interface QueryExecutorfnid - the OID of the backend function to invokeparameters - a ParameterList returned from QueryExecutor.createFastpathParameters(int)
containing the parameters to pass to the backend functionnull
if a void result was returnedjava.sql.SQLException - if an error occurs while executing the fastpath callpublic void processNotifies()
throws java.sql.SQLException
QueryExecutorprocessNotifies in interface QueryExecutorjava.sql.SQLExceptionpublic void execute(Query query, ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws java.sql.SQLException
QueryExecutorexecute in interface QueryExecutorquery - the query to execute; must be a query returned from
calling QueryExecutor.createSimpleQuery(String) or QueryExecutor.createParameterizedQuery(String)
on this QueryExecutor object.parameters - the parameters for the query. Must be non-null
if the query takes parameters. Must be a parameter object returned by
Query.createParameterList().handler - a ResultHandler responsible for handling results generated
by this querymaxRows - the maximum number of rows to retrievefetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspendingflags - a combination of QUERY_* flags indicating how to handle the query.java.sql.SQLException - if query execution failspublic void execute(Query[] queries, ParameterList[] parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws java.sql.SQLException
QueryExecutorexecute in interface QueryExecutorqueries - the queries to execute; each must be a query returned from
calling QueryExecutor.createSimpleQuery(String) or QueryExecutor.createParameterizedQuery(String)
on this QueryExecutor object.parameters - the parameter lists for the queries. The parameter lists
correspond 1:1 to the queries passed in the queries array. Each must be
non-null if the corresponding query takes parameters, and must
be a parameter object returned by Query.createParameterList()
created by the corresponding query.handler - a ResultHandler responsible for handling results generated
by this querymaxRows - the maximum number of rows to retrievefetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspendingflags - a combination of QUERY_* flags indicating how to handle the query.java.sql.SQLException - if query execution failspublic void fetch(ResultCursor cursor, ResultHandler handler, int rows) throws java.sql.SQLException
QueryExecutorfetch in interface QueryExecutorcursor - the cursor to fetch fromhandler - the handler to feed results torows - the preferred number of rows to retrieve before suspendingjava.sql.SQLException - if query execution failsprotected void sendQuery(org.postgresql.core.v2.V2Query query,
org.postgresql.core.v2.SimpleParameterList params,
java.lang.String queryPrefix)
throws java.io.IOException
java.io.IOExceptionprotected void processResults(Query originalQuery, ResultHandler handler, int maxRows, int flags) throws java.io.IOException
java.io.IOExceptionpublic CopyOperation startCopy(java.lang.String sql, boolean suppressBegin) throws java.sql.SQLException
QueryExecutorstartCopy in interface QueryExecutorjava.sql.SQLException - when initializing the given query fails