Thread safety: the prepared statement is not thread-safe. If the same prepared statement is used by multiple threads access to it must be synchronized. The single synchronized block must include assignment of parameters, execution of the command and all operations with its result.
synchronized (prep) {
prep.setInt(1, 10);
try (ResultSet rs = prep.executeQuery()) {
while (rs.next) {
// Do something
}
}
}
synchronized (prep) {
prep.setInt(1, 15);
updateCount = prep.executeUpdate();
}
| Modifier and Type | Field and Description |
|---|---|
| private ArrayList | |
| private HashMap | |
| protected CommandInterface | |
| private final Object |
| Access | Constructor and Description |
|---|---|
| pack-priv | JdbcPreparedStatement(JdbcConnection conn, String sql, int id, int resultSetType, int resultSetConcurrency, Object generatedKeysRequest)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | addBatch(String
ignored sql)Overrides org. Implements java. Calling this method is not legal on a PreparedStatement. |
| public void | |
| public void | clearBatch()
Overrides org. Implements java. Clears the batch. |
| public void | |
| public void | close()
Overrides org. Implements java. Closes this statement. |
| private SQLException | |
| public boolean | Returns: true if a result set is available, false if notImplements java. Executes an arbitrary statement. |
| public int[] | Returns: the array of update countsOverrides org. Implements java. Executes the batch. |
| private BatchResult | |
| public long[] | Returns: the array of update countsOverrides org. Overrides default java. Executes the batch. |
| public long | Returns: the update count (number of affected rows by a DML statement or other statement able to return number of rows, or 0 if no rows were affected or the statement returns nothing)Overrides default java. Executes a statement (insert, update, delete, create, drop) and returns the update count. |
| public ResultSet | Returns: the result setImplements java. Executes a query (select statement) and returns the result set. |
| public ResultSet | executeQuery(String
ignored sql)Overrides org. Implements java. Calling this method is not legal on a PreparedStatement. |
| public int | Returns: the update count (number of affected rows by a DML statement or other statement able to return number of rows, or 0 if no rows were affected or the statement returns nothing, orSUCCESS_NO_INFO if number of rows is too large for
int data type)Implements java. Executes a statement (insert, update, delete, create, drop) and returns the update count. |
| private long | |
| public ResultSetMetaData | Returns: the meta data or null if this is not a queryImplements java. Gets the result set metadata of the query returned when the statement is executed. |
| public ParameterMetaData | Returns: the meta dataImplements java. Get the parameter meta data of this prepared statement. |
| public void | setArray(int
the parameter index (1, 2, ...) parameterIndex, Array the value x)Implements java. Sets the value of a parameter as an Array. |
| public void | setAsciiStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x, int the maximum number of bytes length)Implements java. Sets the value of a parameter as an ASCII stream. |
| public void | setAsciiStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x, long the maximum number of bytes length)Implements java. Sets the value of a parameter as an ASCII stream. |
| public void | setAsciiStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x)Implements java. Sets the value of a parameter as an ASCII stream. |
| public void | setBigDecimal(int
the parameter index (1, 2, ...) parameterIndex, BigDecimal the value x)Implements java. Sets the value of a parameter. |
| public void | setBinaryStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x, long the maximum number of bytes length)Implements java. Sets the value of a parameter as an input stream. |
| public void | setBinaryStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x, int the maximum number of bytes length)Implements java. Sets the value of a parameter as an input stream. |
| public void | setBinaryStream(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x)Implements java. Sets the value of a parameter as an input stream. |
| public void | setBlob(int
the parameter index (1, 2, ...) parameterIndex, Blob the value x)Implements java. Sets the value of a parameter as a Blob. |
| public void | setBlob(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x)Implements java. Sets the value of a parameter as a Blob. |
| public void | setBlob(int
the parameter index (1, 2, ...) parameterIndex, InputStream the value x, long the maximum number of bytes length)Implements java. Sets the value of a parameter as a Blob. |
| public void | setBoolean(int
the parameter index (1, 2, ...) parameterIndex, boolean the value x)Implements java. Sets the value of a parameter. |
| public void | setByte(int
the parameter index (1, 2, ...) parameterIndex, byte the value x)Implements java. Sets the value of a parameter. |
| public void | setBytes(int
the parameter index (1, 2, ...) parameterIndex, byte[] the value x)Implements java. Sets the value of a parameter as a byte array. |
| pack-priv void | setCachedColumnLabelMap(HashMap<String, Integer>
the column map cachedColumnLabelMap)Cache the column labels (looking up the column index can sometimes show up on the performance profile). |
| public void | setCharacterStream(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x, int the maximum number of characters length)Implements java. Sets the value of a parameter as a character stream. |
| public void | setCharacterStream(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x)Implements java. Sets the value of a parameter as a character stream. |
| public void | setCharacterStream(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x, long the maximum number of characters length)Implements java. Sets the value of a parameter as a character stream. |
| public void | setClob(int
the parameter index (1, 2, ...) parameterIndex, Clob the value x)Implements java. Sets the value of a parameter as a Clob. |
| public void | setClob(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x)Implements java. Sets the value of a parameter as a Clob. |
| public void | setClob(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x, long the maximum number of characters length)Implements java. Sets the value of a parameter as a Clob. |
| public void | setDate(int
the parameter index (1, 2, ...) parameterIndex, Date the value x)Implements java. Sets the value of a parameter. |
| public void | setDate(int
the parameter index (1, 2, ...) parameterIndex, Date the value x, Calendar the calendar calendar)Implements java. Sets the date using a specified time zone. |
| public void | setDouble(int
the parameter index (1, 2, ...) parameterIndex, double the value x)Implements java. Sets the value of a parameter. |
| public void | setFloat(int
the parameter index (1, 2, ...) parameterIndex, float the value x)Implements java. Sets the value of a parameter. |
| public void | setInt(int
the parameter index (1, 2, ...) parameterIndex, int the value x)Implements java. Sets the value of a parameter. |
| public void | setLong(int
the parameter index (1, 2, ...) parameterIndex, long the value x)Implements java. Sets the value of a parameter. |
| public void | setNCharacterStream(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x, long the maximum number of characters length)Implements java. Sets the value of a parameter as a character stream. |
| public void | setNCharacterStream(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x)Implements java. Sets the value of a parameter as a character stream. |
| public void | setNClob(int
the parameter index (1, 2, ...) parameterIndex, NClob the value x)Implements java. Sets the value of a parameter as a Clob. |
| public void | setNClob(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x)Implements java. Sets the value of a parameter as a Clob. |
| public void | setNClob(int
the parameter index (1, 2, ...) parameterIndex, Reader the value x, long the maximum number of characters length)Implements java. Sets the value of a parameter as a Clob. |
| public void | setNString(int
the parameter index (1, 2, ...) parameterIndex, String the value x)Implements java. Sets the value of a parameter. |
| public void | setNull(int
the parameter index (1, 2, ...) parameterIndex, int the data type (Types.x) sqlType)Implements java. Sets a parameter to null. |
| public void | setNull(int
the parameter index (1, 2, ...) parameterIndex, int the data type (Types.x) sqlType, String this parameter is ignored typeName)Implements java. Sets a parameter to null. |
| public void | setObject(int
the parameter index (1, 2, ...) parameterIndex, Object the value x)Implements java. Sets the value of a parameter. |
| public void | setObject(int
the parameter index (1, 2, ...) parameterIndex, Object the value, null is allowed x, int the type as defined in java.sql.Types targetSqlType)Implements java. Sets the value of a parameter. |
| public void | setObject(int
the parameter index (1, 2, ...) parameterIndex, Object the value, null is allowed x, int the type as defined in java.sql.Types targetSqlType, int is ignored scale)Implements java. Sets the value of a parameter. |
| public void | setObject(int
the parameter index (1, 2, ...) parameterIndex, Object the value, null is allowed x, SQLType the SQL type targetSqlType)Overrides default java. Sets the value of a parameter. |
| public void | setObject(int
the parameter index (1, 2, ...) parameterIndex, Object the value, null is allowed x, SQLType the SQL type targetSqlType, int is ignored scaleOrLength)Overrides default java. Sets the value of a parameter. |
| private void | |
| private void | |
| public void | setRef(int
the first parameter is 1, the second is 2, ... parameterIndex, Ref an SQL x)REF valueImplements java. [Not supported] Sets the value of a column as a reference. |
| public void | setRowId(int
the first parameter is 1, the second is 2, ... parameterIndex, RowId the parameter value x)Implements java. [Not supported] Sets the value of a parameter as a row id. |
| public void | setShort(int
the parameter index (1, 2, ...) parameterIndex, short the value x)Implements java. Sets the value of a parameter. |
| public void | setSQLXML(int
the parameter index (1, 2, ...) parameterIndex, SQLXML the value x)Implements java. Sets the value of a parameter as a SQLXML. |
| public void | setString(int
the parameter index (1, 2, ...) parameterIndex, String the value x)Implements java. Sets the value of a parameter. |
| public void | setTime(int
the parameter index (1, 2, ...) parameterIndex, Time the value x)Implements java. Sets the value of a parameter. |
| public void | setTime(int
the parameter index (1, 2, ...) parameterIndex, Time the value x, Calendar the calendar calendar)Implements java. Sets the time using a specified time zone. |
| public void | setTimestamp(int
the parameter index (1, 2, ...) parameterIndex, Timestamp the value x)Implements java. Sets the value of a parameter. |
| public void | setTimestamp(int
the parameter index (1, 2, ...) parameterIndex, Timestamp the value x, Calendar the calendar calendar)Implements java. Sets the timestamp using a specified time zone. |
| public void | setUnicodeStream(int
the first parameter is 1, the second is 2, ... parameterIndex, InputStream a x, int java.io.InputStream object that contains the
Unicode parameter valuethe number of bytes in the stream length)Implements java.
Deprecated
since JDBC 2.0, use setCharacterStream
[Not supported] This feature is deprecated and not supported. |
| public void | setURL(int
the first parameter is 1, the second is 2, ... parameterIndex, URL the x)java.net.URL object to be setImplements java. [Not supported] |
| public String |