public class JdbcStatement extends TraceObject implements java.sql.Statement, JdbcStatementBackwardsCompat
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closedByResultSet |
protected JdbcConnection |
conn |
protected int |
fetchSize |
protected JdbcResultSet |
generatedKeys |
protected int |
maxRows |
protected JdbcResultSet |
resultSet |
protected int |
resultSetConcurrency |
protected int |
resultSetType |
protected SessionInterface |
session |
protected int |
updateCount |
ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, SQLXML, STATEMENT, trace, XA_DATA_SOURCE, XID| Modifier and Type | Method and Description |
|---|---|
void |
addBatch(java.lang.String sql)
Adds a statement to the batch.
|
void |
cancel()
Cancels a currently running statement.
|
protected boolean |
checkClosed(boolean write)
INTERNAL.
|
void |
clearBatch()
Clears the batch.
|
void |
clearWarnings()
Clears all warnings.
|
void |
close()
Closes this statement.
|
protected void |
closeOldResultSet()
INTERNAL.
|
void |
closeOnCompletion()
[Not supported]
|
java.lang.String |
enquoteIdentifier(java.lang.String identifier,
boolean alwaysQuote)
Enquotes the specified identifier.
|
boolean |
execute(java.lang.String sql)
Executes an arbitrary statement.
|
boolean |
execute(java.lang.String sql,
int autoGeneratedKeys)
Executes a statement and returns the update count.
|
boolean |
execute(java.lang.String sql,
int[] columnIndexes)
Executes a statement and returns the update count.
|
boolean |
execute(java.lang.String sql,
java.lang.String[] columnNames)
Executes a statement and returns the update count.
|
int[] |
executeBatch()
Executes the batch.
|
long[] |
executeLargeBatch()
Executes the batch.
|
long |
executeLargeUpdate(java.lang.String sql)
Executes a statement (insert, update, delete, create, drop)
and returns the update count.
|
long |
executeLargeUpdate(java.lang.String sql,
int autoGeneratedKeys)
Executes a statement and returns the update count.
|
long |
executeLargeUpdate(java.lang.String sql,
int[] columnIndexes)
Executes a statement and returns the update count.
|
long |
executeLargeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
Executes a statement and returns the update count.
|
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Executes a query (select statement) and returns the result set.
|
int |
executeUpdate(java.lang.String sql)
Executes a statement (insert, update, delete, create, drop)
and returns the update count.
|
int |
executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
Executes a statement and returns the update count.
|
int |
executeUpdate(java.lang.String sql,
int[] columnIndexes)
Executes a statement and returns the update count.
|
int |
executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
Executes a statement and returns the update count.
|
java.sql.Connection |
getConnection()
Returns the connection that created this object.
|
int |
getFetchDirection()
Gets the fetch direction.
|
int |
getFetchSize()
Gets the number of rows suggested to read in one step.
|
java.sql.ResultSet |
getGeneratedKeys()
Return a result set with generated keys from the latest executed command or
an empty result set if keys were not generated or were not requested with
Statement.RETURN_GENERATED_KEYS, column indexes, or column names. |
long |
getLargeMaxRows()
Gets the maximum number of rows for a ResultSet.
|
long |
getLargeUpdateCount()
Returns the last update count of this statement.
|
int |
getLastExecutedCommandType()
INTERNAL.
|
int |
getMaxFieldSize()
Gets the maximum number of bytes for a result set column.
|
int |
getMaxRows()
Gets the maximum number of rows for a ResultSet.
|
boolean |
getMoreResults()
Moves to the next result set - however there is always only one result
set.
|
boolean |
getMoreResults(int current)
Move to the next result set.
|
int |
getQueryTimeout()
Gets the current query timeout in seconds.
|
java.sql.ResultSet |
getResultSet()
Returns the last result set produces by this statement.
|
int |
getResultSetConcurrency()
Gets the result set concurrency created by this object.
|
int |
getResultSetHoldability()
Gets the result set holdability.
|
int |
getResultSetType()
Gets the result set type.
|
int |
getUpdateCount()
Returns the last update count of this statement.
|
java.sql.SQLWarning |
getWarnings()
Gets the first warning reported by calls on this object.
|
boolean |
isCancelled()
Check whether the statement was cancelled.
|
boolean |
isClosed()
Returns whether this statement is closed.
|
boolean |
isCloseOnCompletion()
[Not supported]
|
boolean |
isPoolable()
Returns whether this object is poolable.
|
boolean |
isSimpleIdentifier(java.lang.String identifier)
Checks if specified identifier may be used without quotes.
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
Checks if unwrap can return an object of this class.
|
void |
setCursorName(java.lang.String name)
Sets the name of the cursor.
|
void |
setEscapeProcessing(boolean enable)
Enables or disables processing or JDBC escape syntax.
|
protected void |
setExecutingStatement(CommandInterface c)
INTERNAL.
|
void |
setFetchDirection(int direction)
Sets the fetch direction.
|
void |
setFetchSize(int rows)
Sets the number of rows suggested to read in one step.
|
void |
setLargeMaxRows(long maxRows)
Gets the maximum number of rows for a ResultSet.
|
void |
setMaxFieldSize(int max)
Sets the maximum number of bytes for a result set column.
|
void |
setMaxRows(int maxRows)
Gets the maximum number of rows for a ResultSet.
|
void |
setPoolable(boolean poolable)
Requests that this object should be pooled or not.
|
void |
setQueryTimeout(int seconds)
Sets the current query timeout in seconds.
|
java.lang.String |
toString()
INTERNAL
|
<T> T |
unwrap(java.lang.Class<T> iface)
Return an object of this class if possible.
|
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupportedprotected JdbcConnection conn
protected SessionInterface session
protected JdbcResultSet resultSet
protected int maxRows
protected int fetchSize
protected int updateCount
protected JdbcResultSet generatedKeys
protected final int resultSetType
protected final int resultSetConcurrency
protected final boolean closedByResultSet
public java.sql.ResultSet executeQuery(java.lang.String sql)
throws java.sql.SQLException
executeQuery in interface java.sql.Statementsql - the SQL statement to executejava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - the SQL statementjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic long executeLargeUpdate(java.lang.String sql)
throws java.sql.SQLException
executeLargeUpdate in interface JdbcStatementBackwardsCompatsql - the SQL statementjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic boolean execute(java.lang.String sql)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - the SQL statement to executejava.sql.SQLExceptionpublic java.sql.ResultSet getResultSet()
throws java.sql.SQLException
getResultSet in interface java.sql.Statementjava.sql.SQLExceptionpublic int getUpdateCount()
throws java.sql.SQLException
getUpdateCount in interface java.sql.Statementjava.sql.SQLException - if this object is closed or invalidpublic long getLargeUpdateCount()
throws java.sql.SQLException
getLargeUpdateCount in interface JdbcStatementBackwardsCompatjava.sql.SQLException - if this object is closed or invalidpublic void close()
throws java.sql.SQLException
close in interface java.lang.AutoCloseableclose in interface java.sql.Statementjava.sql.SQLExceptionpublic java.sql.Connection getConnection()
getConnection in interface java.sql.Statementpublic java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Statementjava.sql.SQLExceptionpublic void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Statementjava.sql.SQLExceptionpublic void setCursorName(java.lang.String name)
throws java.sql.SQLException
setCursorName in interface java.sql.Statementname - ignoredjava.sql.SQLException - if this object is closedpublic void setFetchDirection(int direction)
throws java.sql.SQLException
setFetchDirection in interface java.sql.Statementdirection - ignoredjava.sql.SQLException - if this object is closedpublic int getFetchDirection()
throws java.sql.SQLException
getFetchDirection in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic int getMaxRows()
throws java.sql.SQLException
getMaxRows in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic long getLargeMaxRows()
throws java.sql.SQLException
getLargeMaxRows in interface JdbcStatementBackwardsCompatjava.sql.SQLException - if this object is closedpublic void setMaxRows(int maxRows)
throws java.sql.SQLException
setMaxRows in interface java.sql.StatementmaxRows - the number of rows where 0 means no limitjava.sql.SQLException - if this object is closedpublic void setLargeMaxRows(long maxRows)
throws java.sql.SQLException
setLargeMaxRows in interface JdbcStatementBackwardsCompatmaxRows - the number of rows where 0 means no limitjava.sql.SQLException - if this object is closedpublic void setFetchSize(int rows)
throws java.sql.SQLException
setFetchSize in interface java.sql.Statementrows - the number of rowsjava.sql.SQLException - if this object is closedpublic int getFetchSize()
throws java.sql.SQLException
getFetchSize in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic int getResultSetConcurrency()
throws java.sql.SQLException
getResultSetConcurrency in interface java.sql.Statementjava.sql.SQLExceptionpublic int getResultSetType()
throws java.sql.SQLException
getResultSetType in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic int getMaxFieldSize()
throws java.sql.SQLException
getMaxFieldSize in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic void setMaxFieldSize(int max)
throws java.sql.SQLException
setMaxFieldSize in interface java.sql.Statementmax - the maximum size - ignoredjava.sql.SQLException - if this object is closedpublic void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
setEscapeProcessing in interface java.sql.Statementenable - - true (default) or false (no conversion is attempted)java.sql.SQLException - if this object is closedpublic void cancel()
throws java.sql.SQLException
cancel in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic boolean isCancelled()
public int getQueryTimeout()
throws java.sql.SQLException
getQueryTimeout in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic void setQueryTimeout(int seconds)
throws java.sql.SQLException
setQueryTimeout in interface java.sql.Statementseconds - the timeout in seconds - 0 means no timeout, values
smaller 0 will throw an exceptionjava.sql.SQLException - if this object is closedpublic void addBatch(java.lang.String sql)
throws java.sql.SQLException
addBatch in interface java.sql.Statementsql - the SQL statementjava.sql.SQLExceptionpublic void clearBatch()
throws java.sql.SQLException
clearBatch in interface java.sql.Statementjava.sql.SQLExceptionpublic int[] executeBatch()
throws java.sql.SQLException
executeBatch in interface java.sql.Statementjava.sql.SQLExceptionpublic long[] executeLargeBatch()
throws java.sql.SQLException
executeLargeBatch in interface JdbcStatementBackwardsCompatjava.sql.SQLExceptionpublic java.sql.ResultSet getGeneratedKeys()
throws java.sql.SQLException
Statement.RETURN_GENERATED_KEYS, column indexes, or column names.
Generated keys are only returned from inserted rows from INSERT,
MERGE INTO, and MERGE INTO ... USING commands. Generated keys
are not returned if exact values of generated columns were specified
explicitly in SQL command. All columns with inserted generated values are
included in the result if command was executed with
Statement.RETURN_GENERATED_KEYS parameter.
If SQL command inserts multiple rows with generated keys each such inserted
row is returned. Batch methods are also supported. When multiple rows are
returned each row contains only generated values for this row. It's possible
to insert several rows with generated values in different columns with some
specific commands, in this special case the returned result set contains all
used columns, but each row will contain only generated values, columns that
were not generated for this row will contain null values.
H2 treats inserted value as generated in the following cases:
IDENTITY columns and columns
with AUTO_INCREMENT if value was generated automatically (not
specified in command).DEFAULT RANDOM_UUID()) also only if default value
was inserted.INSERT INTO ... VALUES (NEXT VALUE FOR ...)).Exact required columns for the returning result set may be specified on execution of command with names or indexes of columns to limit output or reorder columns in result set. Specifying of some column has no effect on treatment of inserted values as generated or not. If some value is not determined to be generated it will not be returned even on explicit request.
getGeneratedKeys in interface java.sql.Statementjava.sql.SQLException - if this object is closedpublic boolean getMoreResults()
throws java.sql.SQLException
getMoreResults in interface java.sql.Statementjava.sql.SQLException - if this object is closed.public boolean getMoreResults(int current)
throws java.sql.SQLException
getMoreResults in interface java.sql.Statementcurrent - Statement.CLOSE_CURRENT_RESULT,
Statement.KEEP_CURRENT_RESULT,
or Statement.CLOSE_ALL_RESULTSjava.sql.SQLExceptionpublic int executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - the SQL statementautoGeneratedKeys - Statement.RETURN_GENERATED_KEYS if generated keys should
be available for retrieval, Statement.NO_GENERATED_KEYS if
generated keys should not be availablejava.sql.SQLException - if a database error occurred or a
select statement was executedpublic long executeLargeUpdate(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
executeLargeUpdate in interface JdbcStatementBackwardsCompatsql - the SQL statementautoGeneratedKeys - Statement.RETURN_GENERATED_KEYS if generated keys should
be available for retrieval, Statement.NO_GENERATED_KEYS if
generated keys should not be availablejava.sql.SQLException - if a database error occurred or a
select statement was executedpublic int executeUpdate(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - the SQL statementcolumnIndexes - an array of column indexes indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic long executeLargeUpdate(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
executeLargeUpdate in interface JdbcStatementBackwardsCompatsql - the SQL statementcolumnIndexes - an array of column indexes indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic int executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - the SQL statementcolumnNames - an array of column names indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic long executeLargeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
executeLargeUpdate in interface JdbcStatementBackwardsCompatsql - the SQL statementcolumnNames - an array of column names indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic boolean execute(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - the SQL statementautoGeneratedKeys - Statement.RETURN_GENERATED_KEYS if generated keys should
be available for retrieval, Statement.NO_GENERATED_KEYS if
generated keys should not be availablejava.sql.SQLException - if a database error occurred or a
select statement was executedpublic boolean execute(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - the SQL statementcolumnIndexes - an array of column indexes indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic boolean execute(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - the SQL statementcolumnNames - an array of column names indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if a database error occurred or a
select statement was executedpublic int getResultSetHoldability()
throws java.sql.SQLException
getResultSetHoldability in interface java.sql.Statementjava.sql.SQLExceptionpublic void closeOnCompletion()
closeOnCompletion in interface java.sql.Statementpublic boolean isCloseOnCompletion()
isCloseOnCompletion in interface java.sql.Statementprotected boolean checkClosed(boolean write)
write - if the next operation is possibly writingDbException - if it is closedprotected void closeOldResultSet()
throws java.sql.SQLException
java.sql.SQLExceptionprotected void setExecutingStatement(CommandInterface c)
c - the commandpublic int getLastExecutedCommandType()
public boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Statementjava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperiface - the classjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperiface - the classjava.sql.SQLExceptionpublic boolean isPoolable()
isPoolable in interface java.sql.Statementpublic void setPoolable(boolean poolable)
setPoolable in interface java.sql.Statementpoolable - the requested valuepublic java.lang.String enquoteIdentifier(java.lang.String identifier,
boolean alwaysQuote)
throws java.sql.SQLException
JdbcStatementBackwardsCompatenquoteIdentifier in interface JdbcStatementBackwardsCompatidentifier - identifier to quote if required, may be quoted or unquotedalwaysQuote - if true identifier will be quoted unconditionallyjava.sql.SQLException - if identifier is not a valid identifierpublic boolean isSimpleIdentifier(java.lang.String identifier)
throws java.sql.SQLException
JdbcStatementBackwardsCompatisSimpleIdentifier in interface JdbcStatementBackwardsCompatidentifier - identifier to checkjava.sql.SQLExceptionpublic java.lang.String toString()
toString in class java.lang.Object