Top Description Fields Methods
org.postgresql.core

public Interface QueryExecutor

extends TypeTransferModeRegistry
Known Direct Implementers
org.postgresql.core.QueryExecutorBase
Imports
org.postgresql.PGNotification, org.postgresql.copy.CopyOperation, org.postgresql.core.v3.TypeTransferModeRegistry, org.postgresql.jdbc.AutoSave, .BatchResultHandler, .EscapeSyntaxCallMode, .PreferQueryMode, org.postgresql.util.HostSpec, org.checkerframework.checker.nullness.qual.Nullable, java.io.Closeable, .IOException, java.sql.SQLException, .SQLWarning, java.util.List, .Map, .Set, .TimeZone

Abstracts the protocol-specific details of executing a query.

Every connection has a single QueryExecutor implementation associated with it. This object provides:

Query objects may represent a query that has parameter placeholders. To provide actual values for these parameters, a ParameterList object is created via a factory method ( Query#createParameterList). The parameters are filled in by the caller and passed along with the query to the query execution methods. Several ParameterLists for a given query might exist at one time (or over time); this allows the underlying Query to be reused for several executions, or for batch execution of the same Query.

In general, a Query created by a particular QueryExecutor may only be executed by that QueryExecutor, and a ParameterList created by a particular Query may only be used as parameters to that Query. Unpredictable things will happen if this isn't done.

Author
Oliver Jowett ([email protected])

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
QUERY_BOTH_ROWS_AND_STATUS

Flag for query execution used by generated keys where we want to receive both the ResultSet and associated update count from the command status.

public static final int
QUERY_DESCRIBE_ONLY

Flag for query execution when we don't really want to execute, we just want to get the parameter metadata for the statement.

public static final int
QUERY_DISALLOW_BATCHING

Deprecated in PgJDBC 9.4 as we now auto-size batches.
Flag to disable batch execution when we expect results (generated keys) from a statement.
public static final int
QUERY_EXECUTE_AS_SIMPLE

Execute the query via simple 'Q' command (not parse, bind, exec, but simple execute).

public static final int
QUERY_FORCE_DESCRIBE_PORTAL

Force this query to be described at each execution.

public static final int
QUERY_FORWARD_CURSOR

Flag for query execution that indicates a forward-fetch-capable cursor should be used if possible.

public static final int
QUERY_NO_BINARY_TRANSFER

Flag for query execution to avoid using binary transfer.

public static final int
QUERY_NO_METADATA

Flag for query execution that indicates that resultset metadata isn't needed and can be safely omitted.

public static final int
QUERY_NO_RESULTS

Flag for query execution that indicates that a resultset isn't expected and the query executor can safely discard any rows (although the resultset should still appear to be from a resultset-returning query).

public static final int
QUERY_ONESHOT

Flag for query execution that indicates the given Query object is unlikely to be reused.

public static final int
QUERY_READ_ONLY_HINT

Flag indicating that when beginning a transaction, it should be read only.

public static final int
QUERY_SUPPRESS_BEGIN

Flag for query execution that indicates the automatic BEGIN on the first statement when outside a transaction should not be done.

Method Summary

Modifier and TypeMethod and Description
public void
abort()

Abort at network level without sending the Terminate message to the backend.

public void
addBinaryReceiveOid(int
The oid to request with binary encoding.
oid
)

Adds a single oid that should be received using binary encoding.

public void
addBinarySendOid(int
The oid to send with binary encoding.
oid
)

Adds a single oid that should be sent using binary encoding.

public void
addQueryToAdaptiveFetchCache(boolean
state of adaptive fetch used during adding query
adaptiveFetch
,
ResultCursor
Cursor used by resultSet, containing query, have to be able to cast to Portal class.
cursor
)

Add query to adaptive fetch cache inside QueryExecutor.

public CachedQuery
public CachedQuery
public CachedQuery
public CachedQuery
public void
close()

Close this connection cleanly.

public ParameterList

Returns:

a ParameterList suitable for passing to fastpathCall.
createFastpathParameters
(int
the number of parameters the fastpath call will take
count
)
Deprecated This API is somewhat obsolete, as one may achieve similar performance and greater functionality by setting up a prepared statement to define the function call.

Create a new ParameterList implementation suitable for invoking a fastpath function via fastpathCall.

public CachedQuery
createQuery(String sql, boolean escapeProcessing, boolean isParameterized, @Nullable String... columnNames)

public CachedQuery
public Object
createQueryKey(String sql, boolean escapeProcessing, boolean isParameterized, @Nullable String... columnNames)

public Query

Returns:

a new Query object
createSimpleQuery
(String
the SQL for the query to create
sql
)

Create an unparameterized Query object suitable for execution by this QueryExecutor.

public void
execute(Query
the query to execute; must be a query returned from calling wrap(List) on this QueryExecutor object.
query
,
@Nullable ParameterList
the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by org.postgresql.core.Query#createParameterList().
parameters
,
ResultHandler
a ResultHandler responsible for handling results generated by this query
handler
,
int
the maximum number of rows to retrieve
maxRows
,
int
if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
fetchSize
,
int
a combination of QUERY_* flags indicating how to handle the query.
flags
)

Execute a Query, passing results to a provided ResultHandler.

public void
execute(Query
the query to execute; must be a query returned from calling wrap(List) on this QueryExecutor object.
query
,
@Nullable ParameterList
the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by org.postgresql.core.Query#createParameterList().
parameters
,
ResultHandler
a ResultHandler responsible for handling results generated by this query
handler
,
int
the maximum number of rows to retrieve
maxRows
,
int
if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
fetchSize
,
int
a combination of QUERY_* flags indicating how to handle the query.
flags
,
boolean
state of adaptiveFetch to use during execution
adaptiveFetch
)

Execute a Query with adaptive fetch, passing results to a provided ResultHandler.

public void
execute(Query[]
the queries to execute; each must be a query returned from calling wrap(List) on this QueryExecutor object.
queries
,
@Nullable ParameterList[]
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.
parameterLists
,
BatchResultHandler
a ResultHandler responsible for handling results generated by this query
handler
,
int
the maximum number of rows to retrieve
maxRows
,
int
if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
fetchSize
,
int
a combination of QUERY_* flags indicating how to handle the query.
flags
)

Execute several Query, passing results to a provided ResultHandler.

public void
execute(Query[]
the queries to execute; each must be a query returned from calling wrap(List) on this QueryExecutor object.
queries
,
@Nullable ParameterList[]
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.
parameterLists
,
BatchResultHandler
a ResultHandler responsible for handling results generated by this query
handler
,
int
the maximum number of rows to retrieve
maxRows
,
int
if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
fetchSize
,
int
a combination of QUERY_* flags indicating how to handle the query.
flags
,
boolean
state of adaptiveFetch to use during execution
adaptiveFetch
)

Execute several Query with adaptive fetch, passing results to a provided ResultHandler.

public @Nullable byte[]

Returns:

the binary-format result of the fastpath call, or null if a void result was returned
fastpathCall
(int
the OID of the backend function to invoke
fnid
,
ParameterList
a ParameterList returned from createFastpathParameters containing the parameters to pass to the backend function
params
,
boolean
if begin should be suppressed
suppressBegin
)
Deprecated This API is somewhat obsolete, as one may achieve similar performance and greater functionality by setting up a prepared statement to define the function call.

Invoke a backend function via the fastpath interface.

public void
fetch(ResultCursor
the cursor to fetch from
cursor
,
ResultHandler
the handler to feed results to
handler
,
int
the preferred number of rows to retrieve before suspending
fetchSize
,
boolean
state of adaptiveFetch to use during fetching
adaptiveFetch
)

Fetch additional rows from a cursor.

public boolean

Returns:

state of adaptive fetch inside QueryExecutor
getAdaptiveFetch
()

Get state of adaptive fetch inside QueryExecutor.

public int

Returns:

fetch size computed by adaptive fetch size for given query passed inside cursor
getAdaptiveFetchSize
(boolean
state of adaptive fetch, which should be used during retrieving
adaptiveFetch
,
ResultCursor
Cursor used by resultSet, containing query, have to be able to cast to Portal class.
cursor
)

Get fetch size computed by adaptive fetch size for given query.

public String

Returns:

application_name connection property
getApplicationName
()

Returns application_name connection property.

public AutoSave
public int

Returns:

process ID (PID) of the backend server process handling this connection
getBackendPID
()

Return the process ID (PID) of the backend server process handling this connection.

public Set<? extends Integer>

Returns:

The oids to request with binary encoding.
getBinaryReceiveOids
()
Deprecated the method returns a copy of the set, so it is not efficient. Use useBinaryForReceive(int)

Gets the oids that should be received using binary encoding.

public Set<? extends Integer>

Returns:

useBinaryForOids The oids to send with binary encoding.
getBinarySendOids
()
Deprecated the method returns a copy of the set, so it is not efficient. Use useBinaryForSend(int)

Gets the oids that should be sent using binary encoding.

public Closeable

Returns:

action that would close the connection cleanly.
getCloseAction
()

Returns an action that would close the connection cleanly.

public String

Returns:

the database this connection is connected to.
getDatabase
()

public Encoding

Returns:

the current encoding in use by this connection
getEncoding
()

public EscapeSyntaxCallMode
public HostSpec

Returns:

the host and port this connection is connected to.
getHostSpec
()

public boolean

Returns:

the server integer_datetime setting.
getIntegerDateTimes
()

Returns true if server uses integer instead of double for binary date and time encodings.

public int
public PGNotification[]

Returns:

an array of notifications; if there are no notifications, an empty array is returned.
getNotifications
()

Retrieve and clear the set of asynchronous notifications pending on this connection.

public @Nullable String
getParameterStatus(String parameterName)

public Map<String, String>
public PreferQueryMode
public int

Returns:

the version of the implementation
getProtocolVersion
()

public boolean

Returns:

true if we are going to quote identifier provided in the returning array default is true
getQuoteReturningIdentifiers
()

public ReplicationProtocol

Returns:

the ReplicationProtocol instance for this connection.
getReplicationProtocol
()

public String

Returns:

the server version string from the server_version GUC
getServerVersion
()

Return the server version from the server_version GUC.

public int

Returns:

the server version in numeric XXYYZZ form, eg 090401, from server_version_num
getServerVersionNum
()

Get a machine-readable server version.

public boolean

Returns:

true if the server treats string literals according to the SQL standard
getStandardConformingStrings
()

Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.

public @Nullable TimeZone

Returns:

backend timezone in java format.
getTimeZone
()

Returns backend timezone in java format.

public TransactionState

Returns:

a ProtocolConnection.TRANSACTION_* constant.
getTransactionState
()

Get the current transaction state of this connection.

public String

Returns:

the user this connection authenticated as.
getUser
()

public @Nullable SQLWarning

Returns:

the first SQLWarning in the chain; subsequent warnings can be found via SQLWarning.getNextWarning().
getWarnings
()

Retrieve and clear the chain of warnings accumulated on this connection.

public boolean

Returns:

true iff the connection is closed.
isClosed
()

Check if this connection is closed.

public boolean
public boolean
public void
processNotifies()

Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers.

public void
processNotifies(int
number of milliseconds to block for
timeoutMillis
)

Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers.

public void
public void
removeBinaryReceiveOid(int
The oid to request with binary encoding.
oid
)

Remove given oid from the list of oids for binary receive encoding.

public void
removeBinarySendOid(int
The oid to send with binary encoding.
oid
)

Remove given oid from the list of oids for binary send encoding.

public void
removeQueryFromAdaptiveFetchCache(boolean
state of adaptive fetch used during removing query
adaptiveFetch
,
ResultCursor
Cursor used by resultSet, containing query, have to be able to cast to Portal class.
cursor
)

Remove query from adaptive fetch cache inside QueryExecutor

public void
sendQueryCancel()

Sends a query cancellation for this connection.

public void
setAdaptiveFetch(boolean
desired state of adaptive fetch
adaptiveFetch
)

Set state of adaptive fetch inside QueryExecutor.

public void
public void
setBinaryReceiveOids(Set<Integer>
The oids to request with binary encoding.
useBinaryForOids
)

Sets the oids that should be received using binary encoding.

public void
setBinarySendOids(Set<Integer>
The oids to send with binary encoding.
useBinaryForOids
)

Sets the oids that should be sent using binary encoding.

public void
setFlushCacheOnDeallocate(boolean
true if statement cache should be reset when "deallocate/discard" message observed
flushCacheOnDeallocate
)

By default, the connection resets statement cache in case deallocate all/discard all message is observed.

public void
setNetworkTimeout(int milliseconds)

public void
public CopyOperation

Returns:

handler for associated operation
startCopy
(String
input sql
sql
,
boolean
if begin should be suppressed
suppressBegin
)

Issues a COPY FROM STDIN / COPY TO STDOUT statement and returns handler for associated operation.

public boolean
public Query

Returns:

query object ready for execution by this query executor
wrap
(List<NativeQuery>
list of queries in native to database syntax
queries
)

Wrap given native query into a ready for execution format.

Inherited from org.postgresql.core.v3.TypeTransferModeRegistry:
useBinaryForReceiveuseBinaryForSend

Field Detail

MAX_SAVE_POINTSback to summary
public static final int MAX_SAVE_POINTS
QUERY_BOTH_ROWS_AND_STATUSback to summary
public static final int QUERY_BOTH_ROWS_AND_STATUS

Flag for query execution used by generated keys where we want to receive both the ResultSet and associated update count from the command status.

QUERY_DESCRIBE_ONLYback to summary
public static final int QUERY_DESCRIBE_ONLY

Flag for query execution when we don't really want to execute, we just want to get the parameter metadata for the statement.

QUERY_DISALLOW_BATCHINGback to summary
public static final int QUERY_DISALLOW_BATCHING

Deprecated

in PgJDBC 9.4 as we now auto-size batches.

Flag to disable batch execution when we expect results (generated keys) from a statement.

Annotations
@Deprecated
QUERY_EXECUTE_AS_SIMPLEback to summary
public static final int QUERY_EXECUTE_AS_SIMPLE

Execute the query via simple 'Q' command (not parse, bind, exec, but simple execute). This sends query text on each execution, however it supports sending multiple queries separated with ';' as a single command.

QUERY_FORCE_DESCRIBE_PORTALback to summary
public static final int QUERY_FORCE_DESCRIBE_PORTAL

Force this query to be described at each execution. This is done in pipelined batches where we might need to detect mismatched result types.

QUERY_FORWARD_CURSORback to summary
public static final int QUERY_FORWARD_CURSOR

Flag for query execution that indicates a forward-fetch-capable cursor should be used if possible.

QUERY_NO_BINARY_TRANSFERback to summary
public static final int QUERY_NO_BINARY_TRANSFER

Flag for query execution to avoid using binary transfer.

QUERY_NO_METADATAback to summary
public static final int QUERY_NO_METADATA

Flag for query execution that indicates that resultset metadata isn't needed and can be safely omitted.

QUERY_NO_RESULTSback to summary
public static final int QUERY_NO_RESULTS

Flag for query execution that indicates that a resultset isn't expected and the query executor can safely discard any rows (although the resultset should still appear to be from a resultset-returning query).

QUERY_ONESHOTback to summary
public static final int QUERY_ONESHOT

Flag for query execution that indicates the given Query object is unlikely to be reused.

QUERY_READ_ONLY_HINTback to summary
public static final int QUERY_READ_ONLY_HINT

Flag indicating that when beginning a transaction, it should be read only.

QUERY_SUPPRESS_BEGINback to summary
public static final int QUERY_SUPPRESS_BEGIN

Flag for query execution that indicates the automatic BEGIN on the first statement when outside a transaction should not be done.

Method Detail

abortback to summary
public void abort()

Abort at network level without sending the Terminate message to the backend.

addBinaryReceiveOidback to summary
public void addBinaryReceiveOid(int oid)

Adds a single oid that should be received using binary encoding.

Parameters
oid:int

The oid to request with binary encoding.

addBinarySendOidback to summary
public void addBinarySendOid(int oid)

Adds a single oid that should be sent using binary encoding.

Parameters
oid:int

The oid to send with binary encoding.

addQueryToAdaptiveFetchCacheback to summary
public void addQueryToAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)

Add query to adaptive fetch cache inside QueryExecutor.

Parameters
adaptiveFetch:boolean

state of adaptive fetch used during adding query

cursor:ResultCursor

Cursor used by resultSet, containing query, have to be able to cast to Portal class.

borrowCallableQueryback to summary
public CachedQuery borrowCallableQuery(String sql) throws SQLException
borrowQueryback to summary
public CachedQuery borrowQuery(String sql) throws SQLException
borrowQueryByKeyback to summary
public CachedQuery borrowQueryByKey(Object key) throws SQLException
borrowReturningQueryback to summary
public CachedQuery borrowReturningQuery(String sql, @Nullable String[] columnNames) throws SQLException
closeback to summary
public void close()

Close this connection cleanly.

createFastpathParametersback to summary
public ParameterList createFastpathParameters(int count)

Deprecated

This API is somewhat obsolete, as one may achieve similar performance and greater functionality by setting up a prepared statement to define the function call. Then, executing the statement with binary transmission of parameters and results substitutes for a fast-path function call.

Create a new ParameterList implementation suitable for invoking a fastpath function via fastpathCall.

Parameters
count:int

the number of parameters the fastpath call will take

Returns:ParameterList

a ParameterList suitable for passing to fastpathCall.

Annotations
@Deprecated
createQueryback to summary
public CachedQuery createQuery(String sql, boolean escapeProcessing, boolean isParameterized, @Nullable String... columnNames) throws SQLException
createQueryByKeyback to summary
public CachedQuery createQueryByKey(Object key) throws SQLException
createQueryKeyback to summary
public Object createQueryKey(String sql, boolean escapeProcessing, boolean isParameterized, @Nullable String... columnNames)
createSimpleQueryback to summary
public Query createSimpleQuery(String sql) throws SQLException

Create an unparameterized Query object suitable for execution by this QueryExecutor. The provided query string is not parsed for parameter placeholders ('?' characters), and the Query#createParameterList of the returned object will always return an empty ParameterList.

Parameters
sql:String

the SQL for the query to create

Returns:Query

a new Query object

Exceptions
SQLException:
if something goes wrong
executeback to summary
public void execute(Query query, @Nullable ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws SQLException

Execute a Query, passing results to a provided ResultHandler.

Parameters
query:Query

the query to execute; must be a query returned from calling wrap(List) on this QueryExecutor object.

parameters:@Nullable ParameterList

the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by org.postgresql.core.Query#createParameterList().

handler:ResultHandler

a ResultHandler responsible for handling results generated by this query

maxRows:int

the maximum number of rows to retrieve

fetchSize:int

if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending

flags:int

a combination of QUERY_* flags indicating how to handle the query.

Exceptions
SQLException:
if query execution fails
executeback to summary
public void execute(Query query, @Nullable ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws SQLException

Execute a Query with adaptive fetch, passing results to a provided ResultHandler.

Parameters
query:Query

the query to execute; must be a query returned from calling wrap(List) on this QueryExecutor object.

parameters:@Nullable ParameterList

the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by org.postgresql.core.Query#createParameterList().

handler:ResultHandler

a ResultHandler responsible for handling results generated by this query

maxRows:int

the maximum number of rows to retrieve

fetchSize:int

if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending

flags:int

a combination of QUERY_* flags indicating how to handle the query.

adaptiveFetch:boolean

state of adaptiveFetch to use during execution

Exceptions
SQLException:
if query execution fails
executeback to summary
public void execute(Query[] queries, @Nullable ParameterList[] parameterLists, BatchResultHandler handler, int maxRows, int fetchSize, int flags) throws SQLException

Execute several Query, passing results to a provided ResultHandler.

Parameters
queries:Query[]

the queries to execute; each must be a query returned from calling wrap(List) on this QueryExecutor object.

parameterLists:@Nullable ParameterList[]

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:BatchResultHandler

a ResultHandler responsible for handling results generated by this query

maxRows:int

the maximum number of rows to retrieve

fetchSize:int

if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending

flags:int

a combination of QUERY_* flags indicating how to handle the query.

Exceptions
SQLException:
if query execution fails
executeback to summary
public void execute(Query[] queries, @Nullable ParameterList[] parameterLists, BatchResultHandler handler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws SQLException

Execute several Query with adaptive fetch, passing results to a provided ResultHandler.

Parameters
queries:Query[]

the queries to execute; each must be a query returned from calling wrap(List) on this QueryExecutor object.

parameterLists:@Nullable ParameterList[]

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:BatchResultHandler

a ResultHandler responsible for handling results generated by this query

maxRows:int

the maximum number of rows to retrieve

fetchSize:int

if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending

flags:int

a combination of QUERY_* flags indicating how to handle the query.

adaptiveFetch:boolean

state of adaptiveFetch to use during execution

Exceptions
SQLException:
if query execution fails
fastpathCallback to summary
public @Nullable byte[] fastpathCall(int fnid, ParameterList params, boolean suppressBegin) throws SQLException

Deprecated

This API is somewhat obsolete, as one may achieve similar performance and greater functionality by setting up a prepared statement to define the function call. Then, executing the statement with binary transmission of parameters and results substitutes for a fast-path function call.

Invoke a backend function via the fastpath interface.

Parameters
fnid:int

the OID of the backend function to invoke

params:ParameterList

a ParameterList returned from createFastpathParameters containing the parameters to pass to the backend function

suppressBegin:boolean

if begin should be suppressed

Returns:@Nullable byte[]

the binary-format result of the fastpath call, or null if a void result was returned

Annotations
@Deprecated
Exceptions
SQLException:
if an error occurs while executing the fastpath call
fetchback to summary
public void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize, boolean adaptiveFetch) throws SQLException

Fetch additional rows from a cursor.

Parameters
cursor:ResultCursor

the cursor to fetch from

handler:ResultHandler

the handler to feed results to

fetchSize:int

the preferred number of rows to retrieve before suspending

adaptiveFetch:boolean

state of adaptiveFetch to use during fetching

Exceptions
SQLException:
if query execution fails
getAdaptiveFetchback to summary
public boolean getAdaptiveFetch()

Get state of adaptive fetch inside QueryExecutor.

Returns:boolean

state of adaptive fetch inside QueryExecutor

getAdaptiveFetchSizeback to summary
public int getAdaptiveFetchSize(boolean adaptiveFetch, ResultCursor cursor)

Get fetch size computed by adaptive fetch size for given query.

Parameters
adaptiveFetch:boolean

state of adaptive fetch, which should be used during retrieving

cursor:ResultCursor

Cursor used by resultSet, containing query, have to be able to cast to Portal class.

Returns:int

fetch size computed by adaptive fetch size for given query passed inside cursor

getApplicationNameback to summary
public String getApplicationName()

Returns application_name connection property.

Returns:String

application_name connection property

getAutoSaveback to summary
public AutoSave getAutoSave()
getBackendPIDback to summary
public int getBackendPID()

Return the process ID (PID) of the backend server process handling this connection.

Returns:int

process ID (PID) of the backend server process handling this connection

getBinaryReceiveOidsback to summary
public Set<? extends Integer> getBinaryReceiveOids()

Deprecated

the method returns a copy of the set, so it is not efficient. Use useBinaryForReceive(int)

Gets the oids that should be received using binary encoding.

Note

this returns an unmodifiable set, and its contents might not reflect the current state.

Returns:Set<? extends Integer>

The oids to request with binary encoding.

Annotations
@Deprecated
getBinarySendOidsback to summary
public Set<? extends Integer> getBinarySendOids()

Deprecated

the method returns a copy of the set, so it is not efficient. Use useBinaryForSend(int)

Gets the oids that should be sent using binary encoding.

Note

this returns an unmodifiable set, and its contents might not reflect the current state.

Returns:Set<? extends Integer>

useBinaryForOids The oids to send with binary encoding.

Annotations
@Deprecated
getCloseActionback to summary
public Closeable getCloseAction()

Returns an action that would close the connection cleanly. The returned object should refer only the minimum subset of objects required for proper resource cleanup. For instance, it should better not hold a strong reference to QueryExecutor.

Returns:Closeable

action that would close the connection cleanly.

getDatabaseback to summary
public String getDatabase()
Returns:String

the database this connection is connected to.

getEncodingback to summary
public Encoding getEncoding()
Returns:Encoding

the current encoding in use by this connection

getEscapeSyntaxCallModeback to summary
public EscapeSyntaxCallMode getEscapeSyntaxCallMode()
getHostSpecback to summary
public HostSpec getHostSpec()
Returns:HostSpec

the host and port this connection is connected to.

getIntegerDateTimesback to summary
public boolean getIntegerDateTimes()

Returns true if server uses integer instead of double for binary date and time encodings.

Returns:boolean

the server integer_datetime setting.

getNetworkTimeoutback to summary
public int getNetworkTimeout() throws IOException
getNotificationsback to summary
public PGNotification[] getNotifications() throws SQLException

Retrieve and clear the set of asynchronous notifications pending on this connection.

Returns:PGNotification[]

an array of notifications; if there are no notifications, an empty array is returned.

Exceptions
SQLException:
if and error occurs while fetching notifications
getParameterStatusback to summary
public @Nullable String getParameterStatus(String parameterName)
getParameterStatusesback to summary
public Map<String, String> getParameterStatuses()
getPreferQueryModeback to summary
public PreferQueryMode getPreferQueryMode()
getProtocolVersionback to summary
public int getProtocolVersion()
Returns:int

the version of the implementation

getQuoteReturningIdentifiersback to summary
public boolean getQuoteReturningIdentifiers()
Returns:boolean

true if we are going to quote identifier provided in the returning array default is true

getReplicationProtocolback to summary
public ReplicationProtocol getReplicationProtocol()
Returns:ReplicationProtocol

the ReplicationProtocol instance for this connection.

getServerVersionback to summary
public String getServerVersion()

Return the server version from the server_version GUC.

Note that there's no requirement for this to be numeric or of the form x.y.z. PostgreSQL development releases usually have the format x.ydevel e.g. 9.4devel; betas usually x.ybetan e.g. 9.4beta1. The --with-extra-version configure option may add an arbitrary string to this.

Don't use this string for logic, only use it when displaying the server version to the user. Prefer getServerVersionNum() for all logic purposes.

Returns:String

the server version string from the server_version GUC

getServerVersionNumback to summary
public int getServerVersionNum()

Get a machine-readable server version.

This returns the value of the server_version_num GUC. If no such GUC exists, it falls back on attempting to parse the text server version for the major version. If there's no minor version (e.g. a devel or beta release) then the minor version is set to zero. If the version could not be parsed, zero is returned.

Returns:int

the server version in numeric XXYYZZ form, eg 090401, from server_version_num

getStandardConformingStringsback to summary
public boolean getStandardConformingStrings()

Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. Versions up to 8.1 always treated backslashes as escape characters in string-literals. Since 8.2, this depends on the value of the standard_conforming_strings server variable.

Returns:boolean

true if the server treats string literals according to the SQL standard

getTimeZoneback to summary
public @Nullable TimeZone getTimeZone()

Returns backend timezone in java format.

Returns:@Nullable TimeZone

backend timezone in java format.

getTransactionStateback to summary
public TransactionState getTransactionState()

Get the current transaction state of this connection.

Returns:TransactionState

a ProtocolConnection.TRANSACTION_* constant.

getUserback to summary
public String getUser()
Returns:String

the user this connection authenticated as.

getWarningsback to summary
public @Nullable SQLWarning getWarnings()

Retrieve and clear the chain of warnings accumulated on this connection.

Returns:@Nullable SQLWarning

the first SQLWarning in the chain; subsequent warnings can be found via SQLWarning.getNextWarning().

isClosedback to summary
public boolean isClosed()

Check if this connection is closed.

Returns:boolean

true iff the connection is closed.

isColumnSanitiserDisabledback to summary
public boolean isColumnSanitiserDisabled()
isReWriteBatchedInsertsEnabledback to summary
public boolean isReWriteBatchedInsertsEnabled()
processNotifiesback to summary
public void processNotifies() throws SQLException

Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers. The notification retrieval in ProtocolConnection cannot do this as it is prone to deadlock, so the higher level caller must be responsible which requires exposing this method.

Exceptions
SQLException:
if and error occurs while fetching notifications
processNotifiesback to summary
public void processNotifies(int timeoutMillis) throws SQLException

Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers. The notification retrieval in ProtocolConnection cannot do this as it is prone to deadlock, so the higher level caller must be responsible which requires exposing this method. This variant supports blocking for the given time in millis.

Parameters
timeoutMillis:int

number of milliseconds to block for

Exceptions
SQLException:
if and error occurs while fetching notifications
releaseQueryback to summary
public void releaseQuery(CachedQuery cachedQuery)
removeBinaryReceiveOidback to summary
public void removeBinaryReceiveOid(int oid)

Remove given oid from the list of oids for binary receive encoding.

Note

the binary receive for the oid can be re-activated later.

Parameters
oid:int

The oid to request with binary encoding.

removeBinarySendOidback to summary
public void removeBinarySendOid(int oid)

Remove given oid from the list of oids for binary send encoding.

Note

the binary send for the oid can be re-activated later.

Parameters
oid:int

The oid to send with binary encoding.

removeQueryFromAdaptiveFetchCacheback to summary
public void removeQueryFromAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)

Remove query from adaptive fetch cache inside QueryExecutor

Parameters
adaptiveFetch:boolean

state of adaptive fetch used during removing query

cursor:ResultCursor

Cursor used by resultSet, containing query, have to be able to cast to Portal class.

sendQueryCancelback to summary
public void sendQueryCancel() throws SQLException

Sends a query cancellation for this connection.

Exceptions
SQLException:
if something goes wrong.
setAdaptiveFetchback to summary
public void setAdaptiveFetch(boolean adaptiveFetch)

Set state of adaptive fetch inside QueryExecutor.

Parameters
adaptiveFetch:boolean

desired state of adaptive fetch

setAutoSaveback to summary
public void setAutoSave(AutoSave autoSave)
setBinaryReceiveOidsback to summary
public void setBinaryReceiveOids(Set<Integer> useBinaryForOids)

Sets the oids that should be received using binary encoding.

Parameters
useBinaryForOids:Set<Integer>

The oids to request with binary encoding.

setBinarySendOidsback to summary
public void setBinarySendOids(Set<Integer> useBinaryForOids)

Sets the oids that should be sent using binary encoding.

Parameters
useBinaryForOids:Set<Integer>

The oids to send with binary encoding.

setFlushCacheOnDeallocateback to summary
public void setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate)

By default, the connection resets statement cache in case deallocate all/discard all message is observed. This API allows to disable that feature for testing purposes.

Parameters
flushCacheOnDeallocate:boolean

true if statement cache should be reset when "deallocate/discard" message observed

setNetworkTimeoutback to summary
public void setNetworkTimeout(int milliseconds) throws IOException
setPreferQueryModeback to summary
public void setPreferQueryMode(PreferQueryMode mode)
startCopyback to summary
public CopyOperation startCopy(String sql, boolean suppressBegin) throws SQLException

Issues a COPY FROM STDIN / COPY TO STDOUT statement and returns handler for associated operation. Until the copy operation completes, no other database operation may be performed. Implemented for protocol version 3 only.

Parameters
sql:String

input sql

suppressBegin:boolean

if begin should be suppressed

Returns:CopyOperation

handler for associated operation

Exceptions
SQLException:
when initializing the given query fails
willHealOnRetryback to summary
public boolean willHealOnRetry(SQLException e)
wrapback to summary
public Query wrap(List<NativeQuery> queries)

Wrap given native query into a ready for execution format.

Parameters
queries:List<NativeQuery>

list of queries in native to database syntax

Returns:Query

query object ready for execution by this query executor