The object used for executing a static SQL statement and returning the results it produces.
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a current ResultSet object of the statement if an open one exists.
Type parameters
- F
-
The effect type
Attributes
- Companion
- object
- Source
- Statement.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
trait PreparedStatement[F]trait CallableStatement[F]
Members list
Value members
Abstract 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
INSERTorUPDATEstatement
Attributes
- Source
- Statement.scala
Empties this Statement object's current list of SQL commands.
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
- Source
- Statement.scala
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
-
trueif the first result is aResultSetobject;falseif it is an update count or there are no results - 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_KEYSorStatement.NO_GENERATED_KEYS - sql
-
any SQL statement
Attributes
- Returns
-
trueif the first result is aResultSetobject;falseif it is an update count or there are no results - 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.getUpdateCountswill 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.
- 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.getLargeUpdateCountswill 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.
- Source
- Statement.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,UPDATEorDELETE; 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
- 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).
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_KEYSStatement.NO_GENERATED_KEYS - sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT,UPDATEorDELETE; 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
- Source
- Statement.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
SELECTstatement
Attributes
- Returns
-
a
ResultSetobject that contains the data produced by the given query; nevernull - Source
- Statement.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,UPDATEorDELETE; 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
- 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_KEYSStatement.NO_GENERATED_KEYS - sql
-
an SQL Data Manipulation Language (DML) statement, such as
INSERT,UPDATEorDELETE; 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
- 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
ResultSetobject containing the auto-generated key(s) generated by the execution of thisStatementobject - 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
ResultSetobject or there are no more results - 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
-
trueif the next result is aResultSetobject;falseif it is an update count or there are no more results - 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
ResultSetobject orNoneif the result is an update count or there are no more results - 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
ResultSetobject or there are no more results - 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
Statementobject is closed; false if it is still open - Source
- Statement.scala