public class MonetStatement extends MonetWrapper implements Statement
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 Statement's current
ResultSet object if an open one exists.
The current state of this Statement is that it only implements the
executeQuery() which returns a ResultSet where from results can be
read and executeUpdate() which doesn't return the affected rows.
Commit and rollback are implemented, as is the autoCommit mechanism
which relies on server side auto commit.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
Whether this Statement object is closed or not
|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Modifier and Type | Method and 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 warnings reported for 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.
|
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.
|
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.
|
void |
setMaxFieldSize(int max)
Sets the limit for the maximum number of bytes in a ResultSet
column storing character or binary values to the given number of
bytes.
|
void |
setMaxRows(int max)
Sets the limit for the maximum number of rows that any ResultSet 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.
|
isWrapperFor, unwrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecuteLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getLargeMaxRows, getLargeUpdateCount, setLargeMaxRowsisWrapperFor, unwrappublic void addBatch(String sql) throws SQLException
addBatch in interface Statementsql - typically this is a static SQL INSERT or UPDATE statementSQLException - so the PreparedStatement can throw this exceptionpublic void clearBatch()
clearBatch in interface Statementpublic int[] executeBatch()
throws SQLException
executeBatch in interface StatementSQLException - if a database access error occurs. Throws
BatchUpdateException (a subclass of SQLException) if one of the
commands sent to the database fails to execute properlypublic void cancel()
throws SQLException
cancel in interface StatementSQLException - if a database access error occurs or the cancel
operation is not supportedpublic void clearWarnings()
clearWarnings in interface Statementpublic void close()
close in interface AutoCloseableclose in interface Statementpublic boolean execute(String sql) throws SQLException
execute in interface Statementsql - any SQL statementSQLException - if a database access error occurspublic boolean execute(String sql, int autoGeneratedKeys) throws SQLException
execute in interface Statementsql - any SQL statementautoGeneratedKeys - 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 or
Statement.NO_GENERATED_KEYSSQLException - - if a database access error occurs or the
second parameter supplied to this method is not
Statement.RETURN_GENERATED_KEYS or
Statement.NO_GENERATED_KEYS.public boolean execute(String sql, int[] columnIndexes) throws SQLException
execute in interface Statementsql - any SQL statementcolumnIndexes - an array of the indexes of the columns in
the inserted row that should be made available for
retrieval by a call to the method getGeneratedKeysSQLException - if a database access error occurs or the
elements in the int array passed to this method are not
valid column indexespublic boolean execute(String sql, String[] columnNames) throws SQLException
execute in interface Statementsql - any SQL statementcolumnNames - an array of the names of the columns in the
inserted row that should be made available for retrieval
by a call to the method getGeneratedKeysSQLException - if a database access error occurs or the
elements of the String array passed to this method are
not valid column namespublic ResultSet executeQuery(String sql) throws SQLException
executeQuery in interface Statementsql - an SQL statement to be sent to the database, typically a
static SQL SELECT statementSQLException - if a database access error occurs or the given SQL
statement produces anything other than a single ResultSet objectpublic int executeUpdate(String sql) throws SQLException
executeUpdate in interface Statementsql - an SQL INSERT, UPDATE or DELETE statement or an SQL statement
that returns nothingSQLException - if a database access error occurs or the given SQL
statement produces a ResultSet objectpublic int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
executeUpdate in interface Statementsql - must be an SQL INSERT, UPDATE or DELETE statement or
an SQL statement that returns nothingautoGeneratedKeys - - 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_KEYSSQLException - if a database access error occurs, the
given SQL statement returns a ResultSet object, or the
given constant is not one of those allowedpublic int executeUpdate(String sql, int[] columnIndexes) throws SQLException
executeUpdate in interface Statementsql - an SQL INSERT, UPDATE or DELETE statement or an SQL
statement that returns nothing, such as an SQL DDL statementcolumnIndexes - an array of column indexes indicating the
columns that should be returned from the inserted rowSQLException - if a database access error occurs, the SQL
statement returns a ResultSet object, or the second
argument supplied to this method is not an int array
whose elements are valid column indexespublic int executeUpdate(String sql, String[] columnNames) throws SQLException
executeUpdate in interface Statementsql - an SQL INSERT, UPDATE or DELETE statement or an SQL
statement that returns nothing, such as an SQL DDL statementcolumnNames - an array of the names of the columns that
should be returned from the inserted rowSQLException - if a database access error occurs, the SQL
statement returns a ResultSet object, or the second
argument supplied to this method is not a String array
whose elements are valid column namespublic Connection getConnection()
getConnection in interface Statementpublic int getFetchDirection()
getFetchDirection in interface Statementpublic int getFetchSize()
getFetchSize in interface Statementpublic ResultSet getGeneratedKeys() throws SQLException
getGeneratedKeys in interface StatementSQLException - - if a database access error occurspublic int getMaxFieldSize()
getMaxFieldSize in interface Statementpublic int getMaxRows()
getMaxRows in interface Statementpublic boolean getMoreResults()
throws SQLException
getMoreResults in interface StatementSQLException - if a database access error occursgetMoreResults(int current)public boolean getMoreResults(int current)
throws SQLException
getMoreResults in interface Statementcurrent - one of the following Statement constants indicating what
should happen to current ResultSet objects obtained using
the method getResultSet: CLOSE_CURRENT_RESULT,
KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTSSQLException - if a database access error occurspublic int getQueryTimeout()
throws SQLException
getQueryTimeout in interface StatementSQLException - if a database access error occurssetQueryTimeout(int)public ResultSet getResultSet() throws SQLException
getResultSet in interface StatementSQLException - if a database access error occurspublic int getResultSetConcurrency()
getResultSetConcurrency in interface Statementpublic int getResultSetHoldability()
throws SQLException
getResultSetHoldability in interface StatementSQLException - if a database access error occurspublic int getResultSetType()
getResultSetType in interface Statementpublic int getUpdateCount()
throws SQLException
getUpdateCount in interface StatementSQLException - if a database access error occurspublic SQLWarning getWarnings() throws SQLException
getWarnings in interface StatementSQLException - if a database access error occurs or this method is
called on a closed connectionpublic void setCursorName(String name) throws SQLException
setCursorName in interface Statementname - the new cursor name, which must be unique within a
connectionSQLException - if a database access error occurspublic void setEscapeProcessing(boolean enable)
throws SQLException
setEscapeProcessing in interface Statementenable - true to enable escape processing; false to disable
itSQLException - if a database access error occurspublic void setFetchDirection(int direction)
throws SQLException
setFetchDirection in interface Statementdirection - the initial direction for processing rowsSQLException - if a database access error occurs or the given
direction is not one of ResultSet.FETCH_FORWARD,
ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWNpublic void setFetchSize(int rows)
throws SQLException
setFetchSize in interface Statementrows - the number of rows to fetchSQLException - if the condition 0 <= rows <= this.getMaxRows()
is not satisfied.public void setMaxFieldSize(int max)
throws SQLException
setMaxFieldSize in interface Statementmax - the new column size limit in bytes; zero means there
is no limitSQLException - if a database access error occurs or the
condition max >= 0 is not satisfiedpublic void setMaxRows(int max)
throws SQLException
setMaxRows in interface Statementmax - the new max rows limit; zero means there is no limitSQLException - if the condition max >= 0 is not satisfiedpublic void setQueryTimeout(int seconds)
throws SQLException
setQueryTimeout in interface Statementseconds - the new query timeout limit in seconds; zero means
there is no limitSQLException - if a database access error occurs or the
condition seconds >= 0 is not satisfiedpublic boolean isClosed()
public void setPoolable(boolean poolable)
setPoolable in interface Statementpoolable - requests that the statement be pooled if true
and that the statement not be pooled if falsepublic boolean isPoolable()
isPoolable in interface Statementpublic void closeOnCompletion()
throws SQLException
closeOnCompletion in interface StatementSQLException - if this method is called on a closed Statementpublic boolean isCloseOnCompletion()
throws SQLException
isCloseOnCompletion in interface StatementSQLException - if this method is called on a closed StatementCopyright © 2017. All rights reserved.