- All Superinterfaces:
AutoCloseable,Wrapper
- All Known Subinterfaces:
CallableStatement,PreparedStatement
-
Field Summary
Fields
static 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
voidAdds the given SQL command to the current list of commands for this
Statementobject.voidcancel()Cancels 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.voidclose()Releases 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.enquoteIdentifier(String identifier, boolean alwaysQuote) Returns a SQL identifier.
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.
booleanexecute(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.
booleanexecute(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.
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 longexecuteLargeUpdate(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
Statementobject should be made available for retrieval.default longexecuteLargeUpdate(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 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.intexecuteUpdate(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
Statementobject should be made available for retrieval.intexecuteUpdate(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.
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.booleangetMoreResults(int current) Moves 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.booleanisClosed()Retrieves 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 booleanRetrieves whether
identifieris a simple SQL identifier.voidSets the SQL cursor name to the given
String, which will be used by subsequentStatementobjectexecutemethods.voidsetEscapeProcessing(boolean enable) Sets escape processing on or off.
voidsetFetchDirection(int direction) Gives the driver a hint as to the direction in which rows will be processed in
ResultSetobjects created using thisStatementobject.voidsetFetchSize(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
ResultSetobjects generated by thisStatement.default voidsetLargeMaxRows(long max) Sets the limit for the maximum number of rows that any
ResultSetobject generated by thisStatementobject can contain to the given number.voidsetMaxFieldSize(int max) Sets the limit for the maximum number of bytes that can be returned for character and binary column values in a
ResultSetobject produced by thisStatementobject.voidsetMaxRows(int max) Sets the limit for the maximum number of rows that any
ResultSetobject generated by thisStatementobject can contain to the given number.voidsetPoolable(boolean poolable) Requests that a
Statementbe pooled or not pooled.voidsetQueryTimeout(int seconds) Sets the number of seconds the driver will wait for a
Statementobject to execute to the given number of seconds.
-
Field Details
-
CLOSE_CURRENT_RESULT
-
KEEP_CURRENT_RESULT
-
CLOSE_ALL_RESULTS
-
SUCCESS_NO_INFO
-
EXECUTE_FAILED
-
RETURN_GENERATED_KEYS
-
NO_GENERATED_KEYS
-
-
Method Details
-
executeQuery
-
executeUpdate
-
close
-
getMaxFieldSize
-
setMaxFieldSize
-
getMaxRows
-
setMaxRows
-
setEscapeProcessing
-
getQueryTimeout
-
setQueryTimeout
-
cancel
-
getWarnings
-
clearWarnings
-
setCursorName
-
execute
-
getResultSet
-
getUpdateCount
-
getMoreResults
-
setFetchDirection
-
getFetchDirection
-
setFetchSize
-
getFetchSize
-
getResultSetConcurrency
-
getResultSetType
-
addBatch
-
clearBatch
-
executeBatch
-
getConnection
-
getMoreResults
-
getGeneratedKeys
-
executeUpdate
-
executeUpdate
-
executeUpdate
-
execute
-
execute
-
execute
-
getResultSetHoldability
-
isClosed
-
setPoolable
-
isPoolable
-
closeOnCompletion
-
isCloseOnCompletion
-
getLargeUpdateCount
-
setLargeMaxRows
-
getLargeMaxRows
-
executeLargeBatch
-
executeLargeUpdate
-
executeLargeUpdate
-
executeLargeUpdate
-
executeLargeUpdate
-
enquoteLiteral
Returns a
Stringenclosed in single quotes. Any occurrence of a single quote within the string will be replaced by two single quotes.Examples of the conversion: Value Result Hello 'Hello' G'Day 'G''Day' 'G''Day' '''G''''Day''' I'''M 'I''''''M' - Implementation Note:
- JDBC driver implementations may need to provide their own implementation of this method in order to meet the requirements of the underlying datasource.
- Parameters:
val- a character string- Returns:
- A string enclosed by single quotes with every single quote converted to two single quotes
- Throws:
NullPointerException- if val isnullSQLException- if a database access error occurs- Since:
- 9
-
enquoteIdentifier
Returns a SQL identifier. If
identifieris a simple SQL identifier:- Return the original value if
alwaysQuoteisfalse - Return a delimited identifier if
alwaysQuoteistrue
If
identifieris not a simple SQL identifier,identifierwill be enclosed in double quotes if not already present. If the datasource does not support double quotes for delimited identifiers, the identifier should be enclosed by the string returned fromDatabaseMetaData.getIdentifierQuoteString(). If the datasource does not support delimited identifiers, aSQLFeatureNotSupportedExceptionshould be thrown.A
SQLExceptionwill be thrown ifidentifiercontains any characters invalid in a delimited identifier or the identifier length is invalid for the datasource.- Implementation Requirements:
- The default implementation uses the following criteria to
determine a valid simple SQL identifier:
- The string is not enclosed in double quotes
- The first character is an alphabetic character from a through z, or from A through Z
- The name only contains alphanumeric characters or the character "_"
SQLExceptionif:identifiercontains anullcharacter or double quote and is not a simple SQL identifier.- The length of
identifieris less than 1 or greater than 128 characters
Examples of the conversion: identifier alwaysQuote Result Hello false Hello Hello true "Hello" G'Day false "G'Day" "Bruce Wayne" false "Bruce Wayne" "Bruce Wayne" true "Bruce Wayne" GoodDay$ false "GoodDay$" Hello"World false SQLException "Hello"World" false SQLException - Implementation Note:
- JDBC driver implementations may need to provide their own implementation of this method in order to meet the requirements of the underlying datasource.
- Parameters:
identifier- a SQL identifieralwaysQuote- indicates if a simple SQL identifier should be returned as a quoted identifier- Returns:
- A simple SQL identifier or a delimited identifier
- Throws:
SQLException- if identifier is not a valid identifierSQLFeatureNotSupportedException- if the datasource does not support delimited identifiersNullPointerException- if identifier isnull- Since:
- 9
- Return the original value if
-
isSimpleIdentifier
default boolean isSimpleIdentifier
(String identifier) throws SQLException Retrieves whether
identifieris a simple SQL identifier.- Implementation Requirements:
- The default implementation uses the following criteria to
determine a valid simple SQL identifier:
- The string is not enclosed in double quotes
- The first character is an alphabetic character from a through z, or from A through Z
- The string only contains alphanumeric characters or the character "_"
- The string is between 1 and 128 characters in length inclusive
Examples of the conversion: identifier Simple Identifier Hello true G'Day false "Bruce Wayne" false GoodDay$ false Hello"World false "Hello"World" false - Implementation Note:
- JDBC driver implementations may need to provide their own implementation of this method in order to meet the requirements of the underlying datasource.
- Parameters:
identifier- a SQL identifier- Returns:
- true if a simple SQL identifier, false otherwise
- Throws:
NullPointerException- if identifier isnullSQLException- if a database access error occurs- Since:
- 9
-
enquoteNCharLiteral
Returns a
Stringrepresenting a National Character Set Literal enclosed in single quotes and prefixed with a upper case letter N. Any occurrence of a single quote within the string will be replaced by two single quotes.Examples of the conversion: Value Result Hello N'Hello' G'Day N'G''Day' 'G''Day' N'''G''''Day''' I'''M N'I''''''M' N'Hello' N'N''Hello''' - Implementation Note:
- JDBC driver implementations may need to provide their own implementation of this method in order to meet the requirements of the underlying datasource. An implementation of enquoteNCharLiteral may accept a different set of characters than that accepted by the same drivers implementation of enquoteLiteral.
- Parameters:
val- a character string- Returns:
- the result of replacing every single quote character in the argument by two single quote characters where this entire result is then prefixed with 'N'.
- Throws:
NullPointerException- if val isnullSQLException- if a database access error occurs- Since:
- 9
-