GeezerVison is showing docs.oracle.com — Statement (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact2, compact3
java.sql
Interface Statement
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
CLOSE_ALL_RESULTS |
The constant indicating that all ResultSet objects that
have previously been kept open should be closed when calling
getMoreResults.
|
static int |
CLOSE_CURRENT_RESULT |
The constant indicating that the current ResultSet object
should be closed when calling getMoreResults.
|
static int |
EXECUTE_FAILED |
The constant indicating that an error occurred while executing a
batch statement.
|
static int |
KEEP_CURRENT_RESULT |
The constant indicating that the current ResultSet object
should not be closed when calling getMoreResults.
|
static int |
NO_GENERATED_KEYS |
The constant indicating that generated keys should not be made
available for retrieval.
|
static int |
RETURN_GENERATED_KEYS |
The constant indicating that generated keys should be made
available for retrieval.
|
static int |
SUCCESS_NO_INFO |
The constant indicating that a batch statement executed successfully
but that no count of the number of rows it affected is available.
|
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods
| Modifier and Type |
Method |
Description |
void |
addBatch(String sql) |
Adds the given SQL command to the current list of commands for this
Statement object.
|
void |
cancel() |
Cancels this Statement object if both the DBMS and
driver support aborting an SQL statement.
|
void |
clearBatch() |
Empties this Statement object's current list of
SQL commands.
|
void |
clearWarnings() |
Clears all the warnings reported on this Statement
object.
|
void |
close() |
Releases this Statement object's database
and JDBC resources immediately instead of waiting for
this to happen when it is automatically closed.
|
void |
closeOnCompletion() |
Specifies that this Statement will be closed when all its
dependent result sets are closed.
|
boolean |
execute(String sql) |
Executes the given SQL statement, which may return multiple results.
|
boolean |
execute(String sql,
int autoGeneratedKeys) |
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.
|
boolean |
execute(String sql,
int[] columnIndexes) |
Executes 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.
|
boolean |
execute(String sql,
String[] columnNames) |
Executes 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[] |
executeBatch() |
Submits a batch of commands to the database for execution and
if all commands execute successfully, returns an array of update counts.
|
default long[] |
executeLargeBatch() |
Submits a batch of commands to the database for execution and
if all commands execute successfully, returns an array of update counts.
|
default long |
executeLargeUpdate(String sql) |
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.
|
default long |
executeLargeUpdate(String sql,
int autoGeneratedKeys) |
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.
|
default long |
executeLargeUpdate(String sql,
int[] columnIndexes) |
Executes 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 long |
executeLargeUpdate(String sql,
String[] columnNames) |
Executes the given SQL statement and signals the driver that the
auto-generated keys indicated in the given array should be made available
for retrieval.
|
ResultSet |
executeQuery(String sql) |
Executes the given SQL statement, which returns a single
ResultSet object.
|
int |
executeUpdate(String sql) |
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.
|
int |
executeUpdate(String sql,
int autoGeneratedKeys) |
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.
|
int |
executeUpdate(String sql,
int[] columnIndexes) |
Executes the given SQL statement and signals the driver that the
auto-generated keys indicated in the given array should be made available
for retrieval.
|
int |
executeUpdate(String sql,
String[] columnNames) |
Executes the given SQL statement and signals the driver that the
auto-generated keys indicated in the given array should be made available
for retrieval.
|
Connection |
getConnection() |
Retrieves the Connection object
that produced this Statement object.
|
int |
getFetchDirection() |
Retrieves the direction for fetching rows from
database tables that is the default for result sets
generated from this Statement object.
|
int |
getFetchSize() |
Retrieves the number of result set rows that is the default
fetch size for ResultSet objects
generated from this Statement object.
|
ResultSet |
getGeneratedKeys() |
Retrieves any auto-generated keys created as a result of executing this
Statement object.
|
default long |
getLargeMaxRows() |
Retrieves the maximum number of rows that a
ResultSet object produced by this
Statement object can contain.
|
default long |
getLargeUpdateCount() |
Retrieves the current result as an update count; if the result
is a ResultSet object or there are no more results, -1
is returned.
|
int |
getMaxFieldSize() |
Retrieves the maximum number of bytes that can be
returned for character and binary column values in a ResultSet
object produced by this Statement object.
|
int |
getMaxRows() |
Retrieves the maximum number of rows that a
ResultSet object produced by this
Statement object can contain.
|
boolean |
getMoreResults() |
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.
|
boolean |
getMoreResults(int current) |
Moves to this Statement object's next result, deals with
any current ResultSet object(s) according to the instructions
specified by the given flag, and returns
true if the next result is a ResultSet object.
|
int |
getQueryTimeout() |
Retrieves the number of seconds the driver will
wait for a Statement object to execute.
|
ResultSet |
getResultSet() |
Retrieves the current result as a ResultSet object.
|
int |
getResultSetConcurrency() |
Retrieves the result set concurrency for ResultSet objects
generated by this Statement object.
|
int |
getResultSetHoldability() |
Retrieves the result set holdability for ResultSet objects
generated by this Statement object.
|
int |
getResultSetType() |
Retrieves the result set type for ResultSet objects
generated by this Statement object.
|
int |
getUpdateCount() |
Retrieves the current result as an update count;
if the result is a ResultSet object or there are no more results, -1
is returned.
|
SQLWarning |
getWarnings() |
Retrieves the first warning reported by calls on this Statement object.
|
boolean |
isClosed() |
Retrieves whether this Statement object has been closed.
|
boolean |
isCloseOnCompletion() |
Returns a value indicating whether this Statement will be
closed when all its dependent result sets are closed.
|
boolean |
isPoolable() |
Returns a value indicating whether the Statement
is poolable or not.
|
void |
setCursorName(String name) |
Sets the SQL cursor name to the given String, which
will be used by subsequent Statement object
execute methods.
|
void |
setEscapeProcessing(boolean enable) |
Sets escape processing on or off.
|
void |
setFetchDirection(int direction) |
Gives the driver a hint as to the direction in which
rows will be processed in ResultSet
objects created using this Statement object.
|
void |
setFetchSize(int rows) |
Gives the JDBC driver a hint as to the number of rows that should
be fetched from the database when more rows are needed for
ResultSet objects generated by this Statement.
|
default void |
setLargeMaxRows(long max) |
Sets the limit for the maximum number of rows that any
ResultSet object generated by this Statement
object can contain to the given number.
|
void |
setMaxFieldSize(int max) |
Sets the limit for the maximum number of bytes that can be returned for
character and binary column values in a ResultSet
object produced by this Statement object.
|
void |
setMaxRows(int max) |
Sets the limit for the maximum number of rows that any
ResultSet object generated by this Statement
object can contain to the given number.
|
void |
setPoolable(boolean poolable) |
Requests that a Statement be pooled or not pooled.
|
void |
setQueryTimeout(int seconds) |
Sets the number of seconds the driver will wait for a
Statement object to execute to the given number of seconds.
|
-
-
Method Detail
-
getMaxFieldSize
int getMaxFieldSize()
throws SQLException
Retrieves the maximum number of bytes that can be
returned for character and binary column values in a ResultSet
object produced by this Statement object.
This limit applies only to BINARY, VARBINARY,
LONGVARBINARY, CHAR, VARCHAR,
NCHAR, NVARCHAR, LONGNVARCHAR
and LONGVARCHAR columns. If the limit is exceeded, the
excess data is silently discarded.
- Returns:
- the current column size limit for columns storing character and
binary values; zero means there is no limit
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- See Also:
setMaxFieldSize(int)
-
setMaxFieldSize
void setMaxFieldSize(int max)
throws SQLException
Sets the limit for the maximum number of bytes that can be returned for
character and binary column values in a ResultSet
object produced by this Statement object.
This limit applies
only to BINARY, VARBINARY,
LONGVARBINARY, CHAR, VARCHAR,
NCHAR, NVARCHAR, LONGNVARCHAR and
LONGVARCHAR fields. If the limit is exceeded, the excess data
is silently discarded. For maximum portability, use values
greater than 256.
- Parameters:
max - the new column size limit in bytes; zero means there is no limit
- Throws:
SQLException - if a database access error occurs,
this method is called on a closed Statement
or the condition max >= 0 is not satisfied
- See Also:
getMaxFieldSize()
-
getMaxRows
int getMaxRows()
throws SQLException
Retrieves the maximum number of rows that a
ResultSet object produced by this
Statement object can contain. If this limit is exceeded,
the excess rows are silently dropped.
- Returns:
- the current maximum number of rows for a
ResultSet
object produced by this Statement object;
zero means there is no limit
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- See Also:
setMaxRows(int)
-
setMaxRows
void setMaxRows(int max)
throws SQLException
Sets the limit for the maximum number of rows that any
ResultSet object generated by this Statement
object can contain to the given number.
If the limit is exceeded, the excess
rows are silently dropped.
- Parameters:
max - the new max rows limit; zero means there is no limit
- Throws:
SQLException - if a database access error occurs,
this method is called on a closed Statement
or the condition max >= 0 is not satisfied
- See Also:
getMaxRows()
-
getQueryTimeout
int getQueryTimeout()
throws SQLException
Retrieves the number of seconds the driver will
wait for a Statement object to execute.
If the limit is exceeded, a
SQLException is thrown.
- Returns:
- the current query timeout limit in seconds; zero means there is
no limit
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- See Also:
setQueryTimeout(int)
-
cancel
void cancel()
throws SQLException
Cancels this Statement object if both the DBMS and
driver support aborting an SQL statement.
This method can be used by one thread to cancel a statement that
is being executed by another thread.
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
SQLFeatureNotSupportedException - if the JDBC driver does not support
this method
-
clearWarnings
void clearWarnings()
throws SQLException
Clears all the warnings reported on this Statement
object. After a call to this method,
the method getWarnings will return
null until a new warning is reported for this
Statement object.
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
-
getUpdateCount
int getUpdateCount()
throws SQLException
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.
- Returns:
- the current result as an update count; -1 if the current result is a
ResultSet object or there are no more results
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- See Also:
execute(java.lang.String)
-
getFetchDirection
int getFetchDirection()
throws SQLException
Retrieves the direction for fetching rows from
database tables that is the default for result sets
generated from this Statement object.
If this Statement object has not set
a fetch direction by calling the method setFetchDirection,
the return value is implementation-specific.
- Returns:
- the default fetch direction for result sets generated
from this
Statement object
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- Since:
- 1.2
- See Also:
setFetchDirection(int)
-
setFetchSize
void setFetchSize(int rows)
throws SQLException
Gives the JDBC driver a hint as to the number of rows that should
be fetched from the database when more rows are needed for
ResultSet objects generated by this Statement.
If the value specified is zero, then the hint is ignored.
The default value is zero.
- Parameters:
rows - the number of rows to fetch
- Throws:
SQLException - if a database access error occurs,
this method is called on a closed Statement or the
condition rows >= 0 is not satisfied.
- Since:
- 1.2
- See Also:
getFetchSize()
-
getFetchSize
int getFetchSize()
throws SQLException
Retrieves the number of result set rows that is the default
fetch size for ResultSet objects
generated from this Statement object.
If this Statement object has not set
a fetch size by calling the method setFetchSize,
the return value is implementation-specific.
- Returns:
- the default fetch size for result sets generated
from this
Statement object
- Throws:
SQLException - if a database access error occurs or
this method is called on a closed Statement
- Since:
- 1.2
- See Also:
setFetchSize(int)
-
isClosed
boolean isClosed()
throws SQLException
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.
- Returns:
- true if this
Statement object is closed; false if it is still open
- Throws:
SQLException - if a database access error occurs
- Since:
- 1.6
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|