PreparedStatement (Java SE 26 & JDK 26)
- All Superinterfaces:
AutoCloseable, Statement, Wrapper
- All Known Subinterfaces:
CallableStatement
-
Field Summary
Fields declared in interface Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFOstatic final intThe constant indicating that all
ResultSetobjects that have previously been kept open should be closed when callinggetMoreResults.static final intThe constant indicating that the current
ResultSetobject should be closed when callinggetMoreResults.static final intThe constant indicating that an error occurred while executing a batch statement.
static final intThe constant indicating that the current
ResultSetobject should not be closed when callinggetMoreResults.static final intThe constant indicating that generated keys should not be made available for retrieval.
static final intThe constant indicating that generated keys should be made available for retrieval.
static final intThe constant indicating that a batch statement executed successfully but that no count of the number of rows it affected is available.
-
Method Summary
voidaddBatch()Adds a set of parameters to this
PreparedStatementobject's batch of commands.voidClears the current parameter values immediately.
booleanexecute()Executes the SQL statement in this
PreparedStatementobject, which may be any kind of SQL statement.default longExecutes the SQL statement in this
PreparedStatementobject, which must be an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.Executes the SQL query in this
PreparedStatementobject and returns theResultSetobject generated by the query.intExecutes the SQL statement in this
PreparedStatementobject, which must be an SQL Data Manipulation Language (DML) statement, such asINSERT,UPDATEorDELETE; or an SQL statement that returns nothing, such as a DDL statement.Retrieves a
ResultSetMetaDataobject that contains information about the columns of theResultSetobject that will be returned when thisPreparedStatementobject is executed.Retrieves the number, types and properties of this
PreparedStatementobject's parameters.voidsetArray(int parameterIndex, Array x) Sets the designated parameter to the given
java.sql.Arrayobject.voidSets the designated parameter to the given input stream.
voidsetAsciiStream(int parameterIndex, InputStream x, int length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.
voidsetAsciiStream(int parameterIndex, InputStream x, long length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.
voidSets the designated parameter to the given
java.math.BigDecimalvalue.voidSets the designated parameter to the given input stream.
voidSets the designated parameter to the given input stream, which will have the specified number of bytes.
voidsetBinaryStream(int parameterIndex, InputStream x, long length) Sets the designated parameter to the given input stream, which will have the specified number of bytes.
voidSets the designated parameter to a
InputStreamobject.voidsetBlob(int parameterIndex, InputStream inputStream, long length) Sets the designated parameter to a
InputStreamobject.voidsetBlob(int parameterIndex, Blob x) Sets the designated parameter to the given
java.sql.Blobobject.voidsetBoolean(int parameterIndex, boolean x) Sets the designated parameter to the given Java
booleanvalue.voidsetByte(int parameterIndex, byte x) Sets the designated parameter to the given Java
bytevalue.voidsetBytes(int parameterIndex, byte[] x) Sets the designated parameter to the given Java array of bytes.
voidsetCharacterStream(int parameterIndex, Reader reader) Sets the designated parameter to the given
Readerobject.voidsetCharacterStream(int parameterIndex, Reader reader, int length) Sets the designated parameter to the given
Readerobject, which is the given number of characters long.voidsetCharacterStream(int parameterIndex, Reader reader, long length) Sets the designated parameter to the given
Readerobject, which is the given number of characters long.voidsetClob(int parameterIndex, Reader reader) Sets the designated parameter to a
Readerobject.voidsetClob(int parameterIndex, Reader reader, long length) Sets the designated parameter to a
Readerobject.voidsetClob(int parameterIndex, Clob x) Sets the designated parameter to the given
java.sql.Clobobject.voidsetDate(int parameterIndex, Date x) Sets the designated parameter to the given
java.sql.Datevalue using the default time zone of the virtual machine that is running the application.voidSets the designated parameter to the given
java.sql.Datevalue, using the givenCalendarobject.voidsetDouble(int parameterIndex, double x) Sets the designated parameter to the given Java
doublevalue.voidsetFloat(int parameterIndex, float x) Sets the designated parameter to the given Java
floatvalue.voidsetInt(int parameterIndex, int x) Sets the designated parameter to the given Java
intvalue.voidsetLong(int parameterIndex, long x) Sets the designated parameter to the given Java
longvalue.voidsetNCharacterStream(int parameterIndex, Reader value) Sets the designated parameter to a
Readerobject.voidsetNCharacterStream(int parameterIndex, Reader value, long length) Sets the designated parameter to a
Readerobject.voidsetNClob(int parameterIndex, Reader reader) Sets the designated parameter to a
Readerobject.voidsetNClob(int parameterIndex, Reader reader, long length) Sets the designated parameter to a
Readerobject.voidsetNClob(int parameterIndex, NClob value) Sets the designated parameter to a
java.sql.NClobobject.voidsetNString(int parameterIndex, String value) Sets the designated parameter to the given
Stringobject.voidsetNull(int parameterIndex, int sqlType) Sets the designated parameter to SQL
NULL.voidsetNull(int parameterIndex, int sqlType, String typeName) Sets the designated parameter to SQL
NULL.voidsetObject(int parameterIndex, Object x) Sets the value of the designated parameter using the given object.
voidsetObject(int parameterIndex, Object x, int targetSqlType) Sets the value of the designated parameter with the given object.
voidsetObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) Sets the value of the designated parameter with the given object.
default voidSets the value of the designated parameter with the given object.
default voidsetObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) Sets the value of the designated parameter with the given object.
voidsetRef(int parameterIndex, Ref x) Sets the designated parameter to the given
REF(<structured-type>)value.voidsetRowId(int parameterIndex, RowId x) Sets the designated parameter to the given
java.sql.RowIdobject.voidsetShort(int parameterIndex, short x) Sets the designated parameter to the given Java
shortvalue.voidsetSQLXML(int parameterIndex, SQLXML xmlObject) Sets the designated parameter to the given
java.sql.SQLXMLobject.voidsetString(int parameterIndex, String x) Sets the designated parameter to the given Java
Stringvalue.voidsetTime(int parameterIndex, Time x) Sets the designated parameter to the given
java.sql.Timevalue.voidSets the designated parameter to the given
java.sql.Timevalue, using the givenCalendarobject.voidSets the designated parameter to the given
java.sql.Timestampvalue.voidSets the designated parameter to the given
java.sql.Timestampvalue, using the givenCalendarobject.voidvoidsetURL(int parameterIndex, URL x) Sets the designated parameter to the given
java.net.URLvalue.Methods declared in interface Statement
addBatch, cancel, clearBatch, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, execute, executeBatch, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeoutvoidAdds the given SQL command to the current list of commands for this
Statementobject.voidCancels this
Statementobject if both the DBMS and driver support aborting an SQL statement.voidEmpties this
Statementobject's current list of SQL commands.voidClears all the warnings reported on this
Statementobject.voidReleases this
Statementobject's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.voidSpecifies that this
Statementwill be closed when all its dependent result sets are closed.Returns a
Stringenclosed in single quotes.Returns a
Stringrepresenting a National Character Set Literal enclosed in single quotes and prefixed with a upper case letter N.booleanExecutes the given SQL statement, which may return multiple results.
booleanExecutes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval.
booleanExecutes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
booleanExecutes the given SQL statement, which may return multiple results, and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
int[]Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
default long[]Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
default longExecutes the given SQL statement, which may be an
INSERT,UPDATE, orDELETEstatement or an SQL statement that returns nothing, such as an SQL DDL statement.default longExecutes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this
Statementobject should be made available for retrieval.default longExecutes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
default longExecutes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
Executes the given SQL statement, which returns a single
ResultSetobject.intExecutes the given SQL statement, which may be an
INSERT,UPDATE, orDELETEstatement or an SQL statement that returns nothing, such as an SQL DDL statement.intExecutes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this
Statementobject should be made available for retrieval.intExecutes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
intExecutes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
Retrieves the
Connectionobject that produced thisStatementobject.intRetrieves the direction for fetching rows from database tables that is the default for result sets generated from this
Statementobject.intRetrieves the number of result set rows that is the default fetch size for
ResultSetobjects generated from thisStatementobject.Retrieves any auto-generated keys created as a result of executing this
Statementobject.default longRetrieves the maximum number of rows that a
ResultSetobject produced by thisStatementobject can contain.default longRetrieves the current result as an update count; if the result is a
ResultSetobject or there are no more results, -1 is returned.intRetrieves the maximum number of bytes that can be returned for character and binary column values in a
ResultSetobject produced by thisStatementobject.intRetrieves the maximum number of rows that a
ResultSetobject produced by thisStatementobject can contain.booleanMoves to this
Statementobject's next result, returnstrueif it is aResultSetobject, and implicitly closes any currentResultSetobject(s) obtained with the methodgetResultSet.booleanMoves to this
Statementobject's next result, deals with any currentResultSetobject(s) according to the instructions specified by the given flag, and returnstrueif the next result is aResultSetobject.intRetrieves the number of seconds the driver will wait for a
Statementobject to execute.Retrieves the current result as a
ResultSetobject.intRetrieves the result set concurrency for
ResultSetobjects generated by thisStatementobject.intRetrieves the result set holdability for
ResultSetobjects generated by thisStatementobject.intRetrieves the result set type for
ResultSetobjects generated by thisStatementobject.intRetrieves the current result as an update count; if the result is a
ResultSetobject or there are no more results, -1 is returned.Retrieves the first warning reported by calls on this
Statementobject.booleanRetrieves whether this
Statementobject has been closed.booleanReturns a value indicating whether this
Statementwill be closed when all its dependent result sets are closed.booleanReturns a value indicating whether the
Statementis poolable or not.default booleanReturns whether
identifieris a simple SQL identifier.voidSets the SQL cursor name to the given
String, which will be used by subsequentStatementobjectexecutemethods.voidSets escape processing on or off.
voidGives the driver a hint as to the direction in which rows will be processed in
ResultSetobjects created using thisStatementobject.voidGives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for
ResultSetobjects generated by thisStatement.default voidSets the limit for the maximum number of rows that any
ResultSetobject generated by thisStatementobject can contain to the given number.voidSets the limit for the maximum number of bytes that can be returned for character and binary column values in a
ResultSetobject produced by thisStatementobject.voidSets the limit for the maximum number of rows that any
ResultSetobject generated by thisStatementobject can contain to the given number.voidRequests that a
Statementbe pooled or not pooled.voidSets the number of seconds the driver will wait for a
Statementobject to execute to the given number of seconds.Methods declared in interface Wrapper
booleanReturns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.
<T> TReturns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
-
Method Details
-
executeQuery
-
executeUpdate
-
setNull
-
setBoolean
-
setByte
-
setShort
-
setInt
-
setLong
-
setFloat
-
setDouble
-
setBigDecimal
-
setString
-
setBytes
-
setDate
-
setTime
-
setTimestamp
-
setAsciiStream
-
setUnicodeStream
-
setBinaryStream
-
clearParameters
-
setObject
-
setObject
-
execute
-
addBatch
-
setCharacterStream
-
setRef
-
setBlob
-
setClob
-
setArray
-
getMetaData
-
setDate
-
setTime
-
setTimestamp
-
setNull
-
setURL
-
getParameterMetaData
-
setRowId
-
setNString
-
setNCharacterStream
-
setNClob
-
setClob
-
setBlob
-
setNClob
-
setSQLXML
-
setObject
-
setAsciiStream
-
setBinaryStream
-
setCharacterStream
-
setAsciiStream
-
setBinaryStream
-
setCharacterStream
-
setNCharacterStream
-
setClob
-
setBlob
-
setNClob
-
setObject
-
setObject
-
executeLargeUpdate
-