Top Fields Constructors Methods
org.postgresql.jdbc

pack-priv Class PgPreparedStatement

extends PgStatement
implements PreparedStatement
Class Inheritance
All Implemented Interfaces
java.sql.PreparedStatement, java.sql.Statement, java.lang.AutoCloseable, java.sql.Wrapper
Known Direct Subclasses
org.postgresql.jdbc.PgCallableStatement
Static Imports
org.postgresql.util.internal.Nullness.castNonNull

Field Summary

Modifier and TypeField and Description
private @Nullable TimeZone
protected final ParameterList
protected final CachedQuery
Inherited from org.postgresql.jdbc.PgStatement:
adaptiveFetchbatchParametersbatchStatementsconcurrencyconnectionfetchdirectionfetchSizefirstUnclosedResultgeneratedKeyslockmaxFieldSizemaxrowsmPrepareThresholdreplaceProcessingEnabledresultresultsettypetimeoutwantsGeneratedKeysAlwayswantsGeneratedKeysOncewarnings

Constructor Summary

AccessConstructor and Description
pack-priv
PgPreparedStatement(PgConnection connection, String sql, int rsType, int rsConcurrency, int rsHoldability)

pack-priv
PgPreparedStatement(PgConnection connection, CachedQuery query, int rsType, int rsConcurrency, int rsHoldability)

Method Summary

Modifier and TypeMethod and Description
public void
addBatch(String
typically this is a SQL INSERT or UPDATE statement
sql
)

Overrides org.postgresql.jdbc.PgStatement.addBatch.

Implements java.sql.Statement.addBatch.

Adds the given SQL command to the current list of commands for this Statement object.

public void
addBatch()

Implements java.sql.PreparedStatement.addBatch.

Adds a set of parameters to this PreparedStatement object's batch of commands.

private static String
asString(final Clob in)

protected void
bindBytes(@Positive int paramIndex, byte[] b, int oid)

protected void
bindLiteral(@Positive int
parameter index
paramIndex
,
String
value (the value should already be escaped)
s
,
int
type oid
oid
)

Note if s is a String it should be escaped by the caller to avoid SQL injection attacks.

private void
bindString(@Positive int
parameter index
paramIndex
,
String
value
s
,
int
type oid
oid
)

This version is for values that should turn into strings e.g. setString directly calls bindString with no escaping; the per-protocol ParameterList does escaping as needed.

private static PSQLException
cannotCastException(final String fromType, final String toType)

private static PSQLException
cannotCastException(final String fromType, final String toType, final @Nullable Exception cause)

private static BigDecimal
castToBigDecimal(final Object in, final int scale)

private static double
castToDouble(final Object in)

private static float
castToFloat(final Object in)

private static int
castToInt(final Object in)

private static long
castToLong(final Object in)

private static short
castToShort(final Object in)

private static String
castToString(final Object in)

public void
clearParameters()

Implements java.sql.PreparedStatement.clearParameters.

Clears the current parameter values immediately.

public void
closeImpl()

Overrides org.postgresql.jdbc.PgStatement.closeImpl.

This is guaranteed to be called exactly once even in case of concurrent close() calls.

protected long
createBlob(int i, InputStream inputStream, @NonNegative long length)

public ParameterMetaData
public boolean
execute(String
any SQL statement
sql
)

Overrides org.postgresql.jdbc.PgStatement.execute.

Implements java.sql.Statement.execute.

Executes the given SQL statement, which may return multiple results.

public boolean
execute()

Implements java.sql.PreparedStatement.execute.

Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.

public int[]
executeBatch()

Overrides org.postgresql.jdbc.PgStatement.executeBatch.

Implements java.sql.Statement.executeBatch.

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.

public long
executeLargeUpdate()

Overrides default java.sql.PreparedStatement.executeLargeUpdate.

Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.

public ResultSet
executeQuery(String
an SQL statement to be sent to the database, typically a static SQL SELECT statement
sql
)

Overrides org.postgresql.jdbc.PgStatement.executeQuery.

Implements java.sql.Statement.executeQuery.

Executes the given SQL statement, which returns a single ResultSet object.

public ResultSet
executeQuery()

Implements java.sql.PreparedStatement.executeQuery.

Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.

public int
executeUpdate(String
an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
sql
)

Overrides org.postgresql.jdbc.PgStatement.executeUpdate.

Implements java.sql.Statement.executeUpdate.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

public int
executeUpdate()

Implements java.sql.PreparedStatement.executeUpdate.

Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.

public boolean
executeWithFlags(int
additional QueryExecutor flags for execution; these are bitwise-ORed into the default flags.
flags
)

Overrides org.postgresql.jdbc.PgStatement.executeWithFlags.

Implements org.postgresql.core.BaseStatement.executeWithFlags.

Execute a prepared query, passing additional query flags.

private Class<?>
private Calendar
public @Nullable ResultSetMetaData
getMetaData()

Implements java.sql.PreparedStatement.getMetaData.

Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed.

public ParameterMetaData
getParameterMetaData()

Implements java.sql.PreparedStatement.getParameterMetaData.

Retrieves the number, types and properties of this PreparedStatement object's parameters.

private int
protected boolean
public boolean
isUseServerPrepare()

Overrides org.postgresql.jdbc.PgStatement.isUseServerPrepare.

Implements org.postgresql.PGStatement.isUseServerPrepare.

Checks if this statement will be executed as a server-prepared statement.

pack-priv final int
private String
readerToString(Reader value, int maxLength)

public void
setArray(int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Array
an Array object that maps an SQL ARRAY value
x
)

Implements java.sql.PreparedStatement.setArray.

Sets the designated parameter to the given java.sql.Array object.

public void
setAsciiStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the Java input stream that contains the ASCII parameter value
x
,
@NonNegative int
the number of bytes in the stream
length
)

Implements java.sql.PreparedStatement.setAsciiStream.

Sets the designated parameter to the given input stream, which will have the specified number of bytes.

public void
setAsciiStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the Java input stream that contains the ASCII parameter value
value
,
@NonNegative long
the number of bytes in the stream
length
)

Implements java.sql.PreparedStatement.setAsciiStream.

Sets the designated parameter to the given input stream, which will have the specified number of bytes.

public void
setAsciiStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the Java input stream that contains the ASCII parameter value
value
)

Implements java.sql.PreparedStatement.setAsciiStream.

Sets the designated parameter to the given input stream.

public void
setBigDecimal(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable BigDecimal
the parameter value
x
)

Implements java.sql.PreparedStatement.setBigDecimal.

Sets the designated parameter to the given java.math.BigDecimal value.

public void
setBinaryStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the java input stream which contains the binary parameter value
x
,
@NonNegative int
the number of bytes in the stream
length
)

Implements java.sql.PreparedStatement.setBinaryStream.

Sets the designated parameter to the given input stream, which will have the specified number of bytes.

public void
setBinaryStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the java input stream which contains the binary parameter value
value
,
@NonNegative @IntRange(from: 0L, to: 2147483647L) long
the number of bytes in the stream
length
)

Implements java.sql.PreparedStatement.setBinaryStream.

Sets the designated parameter to the given input stream, which will have the specified number of bytes.

public void
setBinaryStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
the java input stream which contains the binary parameter value
value
)

Implements java.sql.PreparedStatement.setBinaryStream.

Sets the designated parameter to the given input stream.

public void
setBlob(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Blob
a Blob object that maps an SQL BLOB value
x
)

Implements java.sql.PreparedStatement.setBlob.

Sets the designated parameter to the given java.sql.Blob object.

public void
setBlob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
An object that contains the data to set the parameter value to.
inputStream
,
@NonNegative long
the number of bytes in the parameter data.
length
)

Implements java.sql.PreparedStatement.setBlob.

Sets the designated parameter to a InputStream object.

public void
setBlob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
An object that contains the data to set the parameter value to.
inputStream
)

Implements java.sql.PreparedStatement.setBlob.

Sets the designated parameter to a InputStream object.

public void
setBoolean(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
boolean
the parameter value
x
)

Implements java.sql.PreparedStatement.setBoolean.

Sets the designated parameter to the given Java boolean value.

public void
setByte(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
byte
the parameter value
x
)

Implements java.sql.PreparedStatement.setByte.

Sets the designated parameter to the given Java byte value.

public void
setBytes(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable byte[]
the parameter value
x
)

Implements java.sql.PreparedStatement.setBytes.

Sets the designated parameter to the given Java array of bytes.

private void
public void
setCharacterStream(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Reader
the java.io.Reader object that contains the Unicode data
x
,
@NonNegative int
the number of characters in the stream
length
)

Implements java.sql.PreparedStatement.setCharacterStream.

Sets the designated parameter to the given Reader object, which is the given number of characters long.

public void
setCharacterStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
the java.io.Reader object that contains the Unicode data
value
,
@NonNegative long
the number of characters in the stream
length
)

Implements java.sql.PreparedStatement.setCharacterStream.

Sets the designated parameter to the given Reader object, which is the given number of characters long.

public void
setCharacterStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
the java.io.Reader object that contains the Unicode data
value
)

Implements java.sql.PreparedStatement.setCharacterStream.

Sets the designated parameter to the given Reader object.

private void
setCharacterStreamPost71(@Positive int parameterIndex, @Nullable InputStream x, int length, String encoding)

public void
setClob(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Clob
a Clob object that maps an SQL CLOB value
x
)

Implements java.sql.PreparedStatement.setClob.

Sets the designated parameter to the given java.sql.Clob object.

public void
setClob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
An object that contains the data to set the parameter value to.
reader
,
@NonNegative long
the number of characters in the parameter data.
length
)

Implements java.sql.PreparedStatement.setClob.

Sets the designated parameter to a Reader object.

public void
setClob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
An object that contains the data to set the parameter value to.
reader
)

Implements java.sql.PreparedStatement.setClob.

Sets the designated parameter to a Reader object.

public void
setDate(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Date
the parameter value
x
)

Implements java.sql.PreparedStatement.setDate.

Sets the designated parameter to the given java.sql.Date value using the default time zone of the virtual machine that is running the application.

public void
setDate(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Date
the parameter value
d
,
@Nullable Calendar
the Calendar object the driver will use to construct the date
cal
)

Implements java.sql.PreparedStatement.setDate.

Sets the designated parameter to the given java.sql.Date value, using the given Calendar object.

private void
setDate(@Positive int i, LocalDate localDate)

public void
setDouble(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
double
the parameter value
x
)

Implements java.sql.PreparedStatement.setDouble.

Sets the designated parameter to the given Java double value.

public void
setFloat(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
float
the parameter value
x
)

Implements java.sql.PreparedStatement.setFloat.

Sets the designated parameter to the given Java float value.

public void
setInt(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
int
the parameter value
x
)

Implements java.sql.PreparedStatement.setInt.

Sets the designated parameter to the given Java int value.

public void
setLong(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
long
the parameter value
x
)

Implements java.sql.PreparedStatement.setLong.

Sets the designated parameter to the given Java long value.

private void
setMap(@Positive int parameterIndex, Map<?, ?> x)

public void
setNCharacterStream(@Positive int
of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
the parameter value
value
,
long
the number of characters in the parameter data.
length
)

Implements java.sql.PreparedStatement.setNCharacterStream.

Sets the designated parameter to a Reader object.

public void
setNCharacterStream(@Positive int
of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
the parameter value
value
)

Implements java.sql.PreparedStatement.setNCharacterStream.

Sets the designated parameter to a Reader object.

public void
setNClob(@Positive int
of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable NClob
the parameter value
value
)

Implements java.sql.PreparedStatement.setNClob.

Sets the designated parameter to a java.sql.NClob object.

public void
setNClob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
An object that contains the data to set the parameter value to.
reader
,
@NonNegative long
the number of characters in the parameter data.
length
)

Implements java.sql.PreparedStatement.setNClob.

Sets the designated parameter to a Reader object.

public void
setNClob(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Reader
An object that contains the data to set the parameter value to.
reader
)

Implements java.sql.PreparedStatement.setNClob.

Sets the designated parameter to a Reader object.

public void
setNString(@Positive int
of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable String
the parameter value
value
)

Implements java.sql.PreparedStatement.setNString.

Sets the designated parameter to the given String object.

public void
setNull(int
the first parameter is 1, the second is 2, ...
parameterIndex
,
int
the SQL type code defined in java.sql.Types
sqlType
)

Implements java.sql.PreparedStatement.setNull.

Sets the designated parameter to SQL NULL.

public void
setNull(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
int
a value from java.sql.Types
t
,
@Nullable String
the fully-qualified name of an SQL user-defined type; ignored if the parameter is not a user-defined type or REF
typeName
)

Implements java.sql.PreparedStatement.setNull.

Sets the designated parameter to SQL NULL.

private void
setNumber(@Positive int parameterIndex, @Nullable Number x)

public void
setObject(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Object
the object containing the input parameter value
in
,
int
the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.
targetSqlType
,
int
for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this is the number of digits after the decimal point. For Java Object types InputStream and Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
scale
)

Implements java.sql.PreparedStatement.setObject.

Sets the value of the designated parameter with the given object.

public void
setObject(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Object
the object containing the input parameter value
x
,
int
the SQL type (as defined in java.sql.Types) to be sent to the database
targetSqlType
)

Implements java.sql.PreparedStatement.setObject.

Sets the value of the designated parameter with the given object.

public void
setObject(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Object
the object containing the input parameter value
x
)

Implements java.sql.PreparedStatement.setObject.

Sets the value of the designated parameter using the given object.

public void
setObject(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Object
the object containing the input parameter value
x
,
SQLType
the SQL type to be sent to the database. The scale argument may further qualify this type.
targetSqlType
,
int
for java.sql.JDBCType.DECIMAL or java.sql.JDBCType.NUMERIC types, this is the number of digits after the decimal point. For Java Object types InputStream and Reader, this is the length of the data in the stream or reader. For all other types, this value will be ignored.
scaleOrLength
)

Overrides default java.sql.PreparedStatement.setObject.

Sets the value of the designated parameter with the given object.

public void
setObject(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Object
the object containing the input parameter value
x
,
SQLType
the SQL type to be sent to the database
targetSqlType
)

Overrides default java.sql.PreparedStatement.setObject.

Sets the value of the designated parameter with the given object.

private <A extends @NonNull Object> void
setObjectArray(int parameterIndex, A in)

private void
setPGobject(@Positive int parameterIndex, PGobject x)

public void
setRef(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Ref
an SQL REF value
x
)

Implements java.sql.PreparedStatement.setRef.

Sets the designated parameter to the given REF(<structured-type>) value.

public void
setRowId(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable RowId
the parameter value
x
)

Implements java.sql.PreparedStatement.setRowId.

Sets the designated parameter to the given java.sql.RowId object.

public void
setShort(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
short
the parameter value
x
)

Implements java.sql.PreparedStatement.setShort.

Sets the designated parameter to the given Java short value.

public void
setSQLXML(@Positive int
index of the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable SQLXML
a SQLXML object that maps an SQL XML value
xmlObject
)

Implements java.sql.PreparedStatement.setSQLXML.

Sets the designated parameter to the given java.sql.SQLXML object.

public void
setString(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable String
the parameter value
x
)

Implements java.sql.PreparedStatement.setString.

Sets the designated parameter to the given Java String value.

protected void
setString(@Positive int parameterIndex, @Nullable String x, int oid)

public void
setTime(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Time
the parameter value
x
)

Implements java.sql.PreparedStatement.setTime.

Sets the designated parameter to the given java.sql.Time value.

public void
setTime(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Time
the parameter value
t
,
@Nullable Calendar
the Calendar object the driver will use to construct the time
cal
)

Implements java.sql.PreparedStatement.setTime.

Sets the designated parameter to the given java.sql.Time value, using the given Calendar object.

private void
setTime(@Positive int i, LocalTime localTime)

private void
setTime(@Positive int i, OffsetTime offsetTime)

public void
setTimestamp(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable Timestamp
the parameter value
x
)

Implements java.sql.PreparedStatement.setTimestamp.

Sets the designated parameter to the given java.sql.Timestamp value.

public void
setTimestamp(@Positive int
the first parameter is 1, the second is 2, ...
i
,
@Nullable Timestamp
the parameter value
t
,
@Nullable Calendar
the Calendar object the driver will use to construct the timestamp
cal
)

Implements java.sql.PreparedStatement.setTimestamp.

Sets the designated parameter to the given java.sql.Timestamp value, using the given Calendar object.

private void
setTimestamp(@Positive int i, LocalDateTime localDateTime)

private void
setTimestamp(@Positive int i, OffsetDateTime offsetDateTime)

public void
setUnicodeStream(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable InputStream
a java.io.InputStream object that contains the Unicode parameter value
x
,
@NonNegative int
the number of bytes in the stream
length
)

Implements java.sql.PreparedStatement.setUnicodeStream.

Sets the designated parameter to the given input stream, which will have the specified number of bytes.

public void
setURL(@Positive int
the first parameter is 1, the second is 2, ...
parameterIndex
,
@Nullable URL
the java.net.URL object to be set
x
)

Implements java.sql.PreparedStatement.setURL.

Sets the designated parameter to the given java.net.URL value.

private void
setUuid(@Positive int parameterIndex, UUID uuid)

public String

Returns:

SQL statement with the current template values substituted
toString
()

Overrides java.lang.Object.toString.

Returns the SQL statement with the current template values substituted.

protected void
Inherited from org.postgresql.jdbc.PgStatement:
addWarningcancelcancelIfStillNeededcheckClosedcheckCompletioncheckNoResultUpdateclearBatchclearWarningsclosecloseForNextExecutioncloseOnCompletioncreateBatchHandlercreateDriverResultSetcreateResultSetexecuteexecuteexecuteexecuteexecuteLargeBatchexecuteLargeUpdateexecuteLargeUpdateexecuteLargeUpdateexecuteLargeUpdateexecuteUpdateexecuteUpdateexecuteUpdateexecuteWithFlagsexecuteWithFlagsgetAdaptiveFetchgetConnectiongetFetchDirectiongetFetchingCursorNamegetFetchSizegetForceBinaryTransfergetGeneratedKeysgetLargeMaxRowsgetLargeUpdateCountgetLastOIDgetMaxFieldSizegetMaxRowsgetMoreResultsgetMoreResultsgetPGConnectiongetPrepareThresholdgetQueryTimeoutgetQueryTimeoutMsgetResultSetgetResultSetConcurrencygetResultSetHoldabilitygetResultSetTypegetSingleResultSetgetTimestampUtilsgetUpdateCountgetWarningsisClosedisCloseOnCompletionisOneShotQueryisPoolableisWrapperForsetAdaptiveFetchsetCursorNamesetEscapeProcessingsetFetchDirectionsetFetchSizesetLargeMaxRowssetMaxFieldSizesetMaxRowssetPoolablesetPrepareThresholdsetQueryTimeoutsetQueryTimeoutMssetUseServerPrepareunwrapwantsHoldableResultSetwantsScrollableResultSet