PreparedStatement
An object that represents a precompiled SQL statement.
A SQL statement is precompiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
Note: The setter methods (setShort, setString, and so on) for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type INTEGER, then the method setInt should be used.
Type parameters
- F
-
The effect type
Attributes
- Source
- PreparedStatement.scala
- Graph
-
- Supertypes
- Known subtypes
-
trait CallableStatement[F]
Members list
Value members
Abstract methods
Adds a set of parameters to this PreparedStatement object's batch of commands.
Adds a set of parameters to this PreparedStatement object's batch of commands.
Attributes
- Source
- PreparedStatement.scala
Executes the SQL statement in this PreparedStatement
object, which may be any kind of SQL statement. Some prepared statements return multiple results; the execute
method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery
and executeUpdate
.
Executes the SQL statement in this PreparedStatement
object, which may be any kind of SQL statement. Some prepared statements return multiple results; the execute
method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery
and executeUpdate
.
The execute
method returns a boolean
to indicate the form of the first result. You must call either the method getResultSet
or getUpdateCount
to retrieve the result; you must call getMoreResults
to move to any subsequent result(s).
Attributes
- Returns
-
true
if the first result is aResultSet
object;false
if the first result is an update count or there is no result - Source
- PreparedStatement.scala
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.
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.
This method should be used when the returned row count may exceed [[Integer#MAX_VALUE]]
.
The default implementation will throw UnsupportedOperationException
Attributes
- Returns
-
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Source
- PreparedStatement.scala
Executes the specified SQL statement and returns one or more ResultSet objects.
Executes the specified SQL statement and returns one or more ResultSet objects.
Attributes
- Source
- PreparedStatement.scala
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.
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.
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
Sets the designated parameter to the given Scala.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala boolean value. The driver converts this to an SQL BIT or BOOLEAN value when it sends it to the database.
Sets the designated parameter to the given Scala boolean value. The driver converts this to an SQL BIT or BOOLEAN value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala byte value. The driver converts this to an SQL TINYINT value when it sends it to the database.
Sets the designated parameter to the given Scala byte value. The driver converts this to an SQL TINYINT value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.
Sets the designated parameter to the given Scala array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given java.time.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
Sets the designated parameter to the given java.time.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala double value. The driver converts this to an SQL DOUBLE value when it sends it to the database.
Sets the designated parameter to the given Scala double value. The driver converts this to an SQL DOUBLE value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala float value. The driver converts this to an SQL REAL value when it ends it to the database.
Sets the designated parameter to the given Scala float value. The driver converts this to an SQL REAL value when it ends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala int value. The driver converts this to an SQL INTEGER value when it sends it to the database.
Sets the designated parameter to the given Scala int value. The driver converts this to an SQL INTEGER value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala long value. The driver converts this to an SQL BIGINT value when it sends it to the database.
Sets the designated parameter to the given Scala long value. The driver converts this to an SQL BIGINT value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to SQL NULL.
Sets the designated parameter to SQL NULL.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
Attributes
- Source
- PreparedStatement.scala
Sets the value of the designated parameter using the given object.
Sets the value of the designated parameter using the given object.
The JDBC specification specifies a standard mapping from Java Object types to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database.
Note that this method may be used to pass datatabase- specific abstract data types, by using a driver-specific Java type. If the object is of a class implementing the interface SQLData, the JDBC driver should call the method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, NClob, Struct, java.net.URL, RowId, SQLXML or Array, the driver should pass it to the database as a value of the corresponding SQL type.
Note: Not all databases allow for a non-typed Null to be sent to the backend. For maximum portability, the setNull or the setObject(parameterIndex: Int, x: Object, sqlType: Int) method should be used instead of setObject(parameterIndex: Int, x: Object).
Note: This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.
Value parameters
- parameterIndex
-
the first parameter is 1, the second is 2, ...
- x
-
the object containing the input parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala short value. The driver converts this to an SQL SMALLINT value when it sends it to the database.
Sets the designated parameter to the given Scala short value. The driver converts this to an SQL SMALLINT value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given Scala String value. The driver converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends it to the database.
Sets the designated parameter to the given Scala String value. The driver converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given java.time.Time value. The driver converts this to an SQL TIME value when it sends it to the database.
Sets the designated parameter to the given java.time.Time value. The driver converts this to an SQL TIME value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Sets the designated parameter to the given java.time.Timestamp value. The driver converts this to an SQL TIMESTAMP value when it sends it to the database.
Sets the designated parameter to the given java.time.Timestamp value. The driver converts this to an SQL TIMESTAMP value when it sends it to the database.
Value parameters
- index
-
the first parameter is 1, the second is 2, ...
- value
-
the parameter value
Attributes
- Source
- PreparedStatement.scala
Concrete methods
Adds the given SQL command to the current list of commands for this Statement
object. The commands in this list can be executed as a batch by calling the method executeBatch
.
Adds the given SQL command to the current list of commands for this Statement
object. The commands in this list can be executed as a batch by calling the method executeBatch
.
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- sql
-
typically this is a SQL
INSERT
orUPDATE
statement
Attributes
- Definition Classes
- Source
- PreparedStatement.scala
Deprecated methods
Executes the given SQL statement, which may return multiple results. In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.
Executes the given SQL statement, which may return multiple results. In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.
The execute
method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet
or getUpdateCount
to retrieve the result, and getMoreResults
to move to any subsequent result(s).
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- sql
-
any SQL statement
Attributes
- Returns
-
true
if the first result is aResultSet
object;false
if it is an update count or there are no results - Deprecated
- true
- Definition Classes
- Source
- PreparedStatement.scala
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.
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.
This method should be used when the returned row count may exceed [[Integer#MAX_VALUE]]
.
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
The default implementation will throw UnsupportedOperationException
Value parameters
- sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT
,UPDATE
orDELETE
; or an SQL statement that returns nothing, such as a DDL statement.
Attributes
- Returns
-
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Deprecated
- true
- Definition Classes
- Source
- PreparedStatement.scala
Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement
object should be made available for retrieval. The driver will ignore the flag if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement
object should be made available for retrieval. The driver will ignore the flag if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
This method should be used when the returned row count may exceed [[Integer#MAX_VALUE]]
.
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
The default implementation will throw SQLFeatureNotSupportedException
Value parameters
- autoGeneratedKeys
-
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants:
Statement.RETURN_GENERATED_KEYS
Statement.NO_GENERATED_KEYS
- sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT
,UPDATE
orDELETE
; or an SQL statement that returns nothing, such as a DDL statement.
Attributes
- Returns
-
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Deprecated
- true
- Definition Classes
- Source
- PreparedStatement.scala
Executes the given SQL statement, which returns a single ResultSet
object.
Executes the given SQL statement, which returns a single ResultSet
object.
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- sql
-
an SQL statement to be sent to the database, typically a static SQL
SELECT
statement
Attributes
- Returns
-
a
ResultSet
object that contains the data produced by the given query; nevernull
- Deprecated
- true
- Definition Classes
- Source
- PreparedStatement.scala
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.
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.
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT
,UPDATE
orDELETE
; or an SQL statement that returns nothing, such as a DDL statement.
Attributes
- Returns
-
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Deprecated
- true
- Definition Classes
- Source
- PreparedStatement.scala
Inherited and Abstract methods
Empties this Statement object's current list of SQL commands.
Empties this Statement object's current list of SQL commands.
Attributes
- Inherited from:
- Statement
- Source
- Statement.scala
Releases this Statement
object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources.
Releases this Statement
object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources.
Calling the method close
on a Statement
object that is already closed has no effect.
Note:When a Statement
object is closed, its current ResultSet
object, if one exists, is also closed.
Attributes
- Inherited from:
- Statement
- Source
- Statement.scala
Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval. The driver will ignore this signal if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
Executes the given SQL statement, which may return multiple results, and signals the driver that any auto-generated keys should be made available for retrieval. The driver will ignore this signal if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.
The execute
method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet
or getUpdateCount
to retrieve the result, and getMoreResults
to move to any subsequent result(s).
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- autoGeneratedKeys
-
a constant indicating whether auto-generated keys should be made available for retrieval using the method
getGeneratedKeys
; one of the following constants:Statement.RETURN_GENERATED_KEYS
orStatement.NO_GENERATED_KEYS
- sql
-
any SQL statement
Attributes
- Returns
-
true
if the first result is aResultSet
object;false
if it is an update count or there are no results - Inherited from:
- Statement
- Source
- Statement.scala
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following:
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following:
- A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
- A value of
SUCCESS_NO_INFO
-- indicates that the command was processed successfully but that the number of rows affected is unknownIf one of the commands in a batch update fails to execute properly, this method throws a
BatchUpdateException
, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the methodBatchUpdateException.getUpdateCounts
will contain as many elements as there are commands in the batch, and at least one of the elements will be the following: - A value of
EXECUTE_FAILED
-- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails
Attributes
- Returns
-
an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
- Inherited from:
- Statement
- Source
- Statement.scala
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The long
elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeLargeBatch
may be one of the following:
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The long
elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeLargeBatch
may be one of the following:
- A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution
- A value of
SUCCESS_NO_INFO
-- indicates that the command was processed successfully but that the number of rows affected is unknownIf one of the commands in a batch update fails to execute properly, this method throws a
BatchUpdateException
, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the methodBatchUpdateException.getLargeUpdateCounts
will contain as many elements as there are commands in the batch, and at least one of the elements will be the following: - A value of
EXECUTE_FAILED
-- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails
This method should be used when the returned row count may exceed Int.MaxValue.
The default implementation will throw UnsupportedOperationException
Attributes
- Returns
-
an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
- Inherited from:
- Statement
- Source
- Statement.scala
Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement
object should be made available for retrieval. The driver will ignore the flag if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
Executes the given SQL statement and signals the driver with the given flag about whether the auto-generated keys produced by this Statement
object should be made available for retrieval. The driver will ignore the flag if the SQL statement is not an INSERT
statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
Note:This method cannot be called on a PreparedStatement
or CallableStatement
.
Value parameters
- autoGeneratedKeys
-
a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants:
Statement.RETURN_GENERATED_KEYS
Statement.NO_GENERATED_KEYS
- sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT
,UPDATE
orDELETE
; or an SQL statement that returns nothing, such as a DDL statement.
Attributes
- Returns
-
either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
- Inherited from:
- Statement
- Source
- Statement.scala
Retrieves any auto-generated keys created as a result of executing this Statement
object. If this Statement
object did not generate any keys, an empty ResultSet
object is returned.
Retrieves any auto-generated keys created as a result of executing this Statement
object. If this Statement
object did not generate any keys, an empty ResultSet
object is returned.
Note:If the columns which represent the auto-generated keys were not specified, the JDBC driver implementation will determine the columns which best represent the auto-generated keys.
Attributes
- Returns
-
a
ResultSet
object containing the auto-generated key(s) generated by the execution of thisStatement
object - Inherited from:
- Statement
- Source
- Statement.scala
Retrieves the current result as an update count; if the result is a ResultSet
object or there are no more results, -1 is returned. This method should be called only once per result.
Retrieves the current result as an update count; if the result is a ResultSet
object or there are no more results, -1 is returned. This method should be called only once per result.
This method should be used when the returned row count may exceed [[Integer#MAX_VALUE]]
.
The default implementation will throw UnsupportedOperationException
Attributes
- Returns
-
the current result as an update count; -1 if the current result is a
ResultSet
object or there are no more results - Inherited from:
- Statement
- Source
- Statement.scala
Moves to this Statement
object's next result, returns true
if it is a ResultSet
object, and implicitly closes any current ResultSet
object(s) obtained with the method getResultSet
.
Moves to this Statement
object's next result, returns true
if it is a ResultSet
object, and implicitly closes any current ResultSet
object(s) obtained with the method getResultSet
.
There are no more results when the following is true: {{{ ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1)) }}}
Attributes
- Returns
-
true
if the next result is aResultSet
object;false
if it is an update count or there are no more results - Inherited from:
- Statement
- Source
- Statement.scala
Retrieves the current result as a ResultSet
object. This method should be called only once per result.
Retrieves the current result as a ResultSet
object. This method should be called only once per result.
Attributes
- Returns
-
the current result as a
ResultSet
object orNone
if the result is an update count or there are no more results - Inherited from:
- Statement
- Source
- Statement.scala
Retrieves the current result as an update count; if the result is a ResultSet
object or there are no more results, -1 is returned. This method should be called only once per result.
Retrieves the current result as an update count; if the result is a ResultSet
object or there are no more results, -1 is returned. This method should be called only once per result.
Attributes
- Returns
-
the current result as an update count; -1 if the current result is a
ResultSet
object or there are no more results - Inherited from:
- Statement
- Source
- Statement.scala
Retrieves whether this Statement
object has been closed. A Statement
is closed if the method close has been called on it, or if it is automatically closed.
Retrieves whether this Statement
object has been closed. A Statement
is closed if the method close has been called on it, or if it is automatically closed.
Attributes
- Returns
-
true if this
Statement
object is closed; false if it is still open - Inherited from:
- Statement
- Source
- Statement.scala