|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.objectweb.cjdbc.driver.Statement
A Statement object is used for executing a static SQL
statement and obtaining the results produced by it.
Only one ResultSet per Statement can
be open at any point in time. Therefore, if the reading of one
ResultSet is interleaved with the reading of another,
each must have been generated by different Statements.
All Statements execute methods implicitly close a
statement's current ResultSet if an open one exists.
Statement,
ResultSet| Field Summary | |
private java.util.Vector |
batch
Vector for batch commands |
protected Connection |
connection
The connection that created us |
protected boolean |
escapeProcessing
Should the driver to escape processing before sending to the DB? |
protected java.sql.ResultSet |
generatedKeys
Auto generated keys |
protected int |
generatedKeysFlag
|
private int |
maxFieldSize
Maximum field size (unused) |
private int |
maxRows
Maximum number of rows (unused) |
private java.sql.ResultSet |
result
The current result for a read request |
private int |
resultSetType
Type of the ResultSet defaults to TYPE_FORWARD_ONLY |
private int |
timeout
Query timeout in seconds (0 means no timeout) |
private int |
updateCount
The update count for a write request |
private java.sql.SQLWarning |
warnings
The warnings chain |
| Fields inherited from interface java.sql.Statement |
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
| Constructor Summary | |
Statement(Connection c)
Creates a new Statement instance. |
|
| Method Summary | |
void |
addBatch(java.lang.String sql)
Adds sql to the current list of commands. |
void |
cancel()
Could be use by one thread to cancel a statement that is being executed by another thread. |
void |
clearBatch()
Empties the current list of commands. |
void |
clearWarnings()
After this call, getWarnings returns
null until a new warning is reported for this
Statement. |
void |
close()
In many cases, it is desirable to immediately release a Statement's database and JDBC resources instead of waiting for this to happen when it is automatically closed. |
boolean |
execute(java.lang.String sql)
Execute a SQL statement that may return multiple results. |
boolean |
execute(java.lang.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(java.lang.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(java.lang.String sql,
java.lang.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()
Execute a batch of commands |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
Execute a SQL statement that returns a single ResultSet |
protected java.sql.ResultSet |
executeQuery(java.lang.String sqlSkeleton,
java.lang.String sqlQuery)
Execute a SQL statement that returns a single ResultSet |
int |
executeUpdate(java.lang.String sql)
Execute a SQL INSERT, UPDATE or DELETE statement. |
int |
executeUpdate(java.lang.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(java.lang.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(java.lang.String sql,
java.lang.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. |
protected int |
executeUpdateWithSkeleton(java.lang.String sqlSkeleton,
java.lang.String sqlQuery)
Execute a SQL INSERT, UPDATE or DELETE statement. |
java.sql.Connection |
getConnection()
Retrieve the connection that created this Statement object |
int |
getFetchDirection()
Not supported yet. |
int |
getFetchSize()
Not supported yet. |
java.sql.ResultSet |
getGeneratedKeys()
Retrieves any auto-generated keys created as a result of executing this Statement object. |
int |
getMaxFieldSize()
The maxFieldSize limit (in bytes) is the maximum amount of data returned for any column value; it only applies to BINARY, VARBINARY,
LONGVARBINARY, CHAR,
VARCHAR and LONGVARCHAR
columns. |
int |
getMaxRows()
The maxRows limit is set to limit the number of rows that any ResultSet can contain. |
boolean |
getMoreResults()
Multiple results are not suppoted so this method always return false and reset the update count to -1. |
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()
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. |
java.sql.ResultSet |
getResultSet()
Returns the current result as a ResultSet. |
int |
getResultSetConcurrency()
Retrieve the concurrency mode for the ResultSet. |
int |
getResultSetHoldability()
Retrieves the result set holdability for ResultSet
objects generated by this Statement object. |
int |
getResultSetType()
Retrieve the type of the generated ResultSet. |
int |
getUpdateCount()
Returns the current result as an update count, if the result is a ResultSet or there are no more results, -1 is
returned. |
java.sql.SQLWarning |
getWarnings()
The first warning reported by calls on this Statement is returned. |
void |
setCursorName(java.lang.String name)
Defines the SQL cursor name that will be used by subsequent execute methods. |
void |
setEscapeProcessing(boolean enable)
If escape scanning is on (the default), the driver will do escape substitution before sending the SQL to the database. |
void |
setFetchDirection(int direction)
Not supported yet. |
void |
setFetchSize(int rows)
Not supported yet. |
void |
setMaxFieldSize(int max)
Sets the maxFieldSize. |
void |
setMaxRows(int max)
Sets the maximum number of rows. |
void |
setQueryTimeout(int seconds)
Sets the queryTimeout limit. |
void |
setResultSetConcurrency(int value)
|
void |
setResultSetType(int value)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Connection connection
private java.util.Vector batch
private java.sql.SQLWarning warnings
private java.sql.ResultSet result
private int updateCount
private int timeout
private int resultSetType
private int maxFieldSize
private int maxRows
protected boolean escapeProcessing
protected java.sql.ResultSet generatedKeys
protected int generatedKeysFlag
| Constructor Detail |
public Statement(Connection c)
Statement instance.
c - the Connection that created us| Method Detail |
public void addBatch(java.lang.String sql)
throws java.sql.SQLException
addBatch in interface java.sql.Statementsql - an SQL statement that returns an update count (INSERT
or UPDATE)
java.sql.SQLException - if an error occurs
public void cancel()
throws java.sql.SQLException
cancel in interface java.sql.Statementjava.sql.SQLException - if an error occurs
public void clearBatch()
throws java.sql.SQLException
clearBatch in interface java.sql.Statementjava.sql.SQLException - if an error occurs
public void clearWarnings()
throws java.sql.SQLException
getWarnings returns
null until a new warning is reported for this
Statement.
clearWarnings in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs (why?)
public int[] executeBatch()
throws java.sql.SQLException
executeBatch in interface java.sql.Statementjava.sql.SQLException - if an error occurs
public void close()
throws java.sql.SQLException
Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed, its current ResultSet, if one exists, is also closed.
close in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs (why?)
public boolean execute(java.lang.String sql)
throws java.sql.SQLException
execute in interface java.sql.Statementsql - any SQL statement
java.sql.SQLException - if an error occurs
public java.sql.ResultSet executeQuery(java.lang.String sql)
throws java.sql.SQLException
executeQuery in interface java.sql.Statementsql - typically a static SQL SELECT statement
java.sql.SQLException - if a database access error occurs
protected java.sql.ResultSet executeQuery(java.lang.String sqlSkeleton,
java.lang.String sqlQuery)
throws java.sql.SQLException
sqlSkeleton - the SQL request squeleton or nullsqlQuery - typically a static SQL SELECT statement that is already trimed
java.sql.SQLException - if a database access error occurs
public int executeUpdate(java.lang.String sql)
throws java.sql.SQLException
executeUpdate in interface java.sql.Statementsql - a SQL statement
java.sql.SQLException - if a database access error occurs
protected int executeUpdateWithSkeleton(java.lang.String sqlSkeleton,
java.lang.String sqlQuery)
throws java.sql.SQLException
sqlSkeleton - the SQL request squeleton or nullsqlQuery - a static SQL statement that is already trimed
java.sql.SQLException - if a database access error occurs
public java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface java.sql.Statementjava.sql.Connection object
java.sql.SQLException - never
public int getFetchDirection()
throws java.sql.SQLException
getFetchDirection in interface java.sql.Statementjava.sql.SQLException - not supported
public int getFetchSize()
throws java.sql.SQLException
getFetchSize in interface java.sql.Statementjava.sql.SQLException - not supported
public int getMaxFieldSize()
throws java.sql.SQLException
BINARY, VARBINARY,
LONGVARBINARY, CHAR,
VARCHAR and LONGVARCHAR
columns. If the limit is exceeded, the excess data is silently
discarded.
Note: We don't do anything with this value yet.
getMaxFieldSize in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs
public int getMaxRows()
throws java.sql.SQLException
ResultSet can contain. If the limit is exceeded, the
excess rows are silently dropped.
getMaxRows in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs
public boolean getMoreResults()
throws java.sql.SQLException
getMoreResults in interface java.sql.Statementjava.sql.SQLException - if an error occurs
public int getQueryTimeout()
throws java.sql.SQLException
SQLException is thrown.
getQueryTimeout in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs
public java.sql.ResultSet getResultSet()
throws java.sql.SQLException
ResultSet.
getResultSet in interface java.sql.Statementjava.sql.SQLException - never
public int getResultSetConcurrency()
throws java.sql.SQLException
ResultSet.
getResultSetConcurrency in interface java.sql.StatementCONCUR_READ_ONLY
java.sql.SQLException - never
public int getResultSetType()
throws java.sql.SQLException
ResultSet.
getResultSetType in interface java.sql.StatementTYPE_FORWARD_ONLY or
TYPE_SCROLL_INSENSITIVE
java.sql.SQLException - never
public int getUpdateCount()
throws java.sql.SQLException
ResultSet or there are no more results, -1 is
returned. It should only be called once per result.
getUpdateCount in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs
public java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
Statement warnings will be chained
to this SQLWarning.
The Warning chain is automatically cleared each time a statement is (re)executed.
Note: if you are processing a ResultSet
then any warnings associated with ResultSet reads
will be chained on the ResultSet object.
getWarnings in interface java.sql.Statementjava.sql.SQLException - if a database access error occurs
public void setCursorName(java.lang.String name)
throws java.sql.SQLException
This is not supported yet and should not be before a very long time.
setCursorName in interface java.sql.Statementname - the new cursor name
java.sql.SQLException - not supported
public void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
setEscapeProcessing in interface java.sql.Statementenable - true to enable; false to disable
java.sql.SQLException - if a database access error occurs
public void setFetchDirection(int direction)
throws java.sql.SQLException
setFetchDirection in interface java.sql.Statementdirection - ignored
java.sql.SQLException - not supported
public void setFetchSize(int rows)
throws java.sql.SQLException
setFetchSize in interface java.sql.Statementrows - ignored
java.sql.SQLException - not supported
public void setMaxFieldSize(int max)
throws java.sql.SQLException
maxFieldSize.
setMaxFieldSize in interface java.sql.Statementmax - the new max column size limit; 0 means unlimited
java.sql.SQLException - if a database access error occurs
public void setMaxRows(int max)
throws java.sql.SQLException
setMaxRows in interface java.sql.Statementmax - the new max rows limit; 0 means unlimited
java.sql.SQLException - if a database access error occurs
public void setQueryTimeout(int seconds)
throws java.sql.SQLException
setQueryTimeout in interface java.sql.Statementseconds - the new query timeout limit in seconds (0 means no
timeout)
java.sql.SQLException - if a database access error occurs
public void setResultSetConcurrency(int value)
throws java.sql.SQLException
value - an int value
java.sql.SQLException - if an error occurs
public void setResultSetType(int value)
throws java.sql.SQLException
value - an int value
java.sql.SQLException - if an error occurs
public boolean getMoreResults(int current)
throws java.sql.SQLException
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.
There are no more results when the following is
true:
(!getMoreResults() && (getUpdateCount() == -1)
getMoreResults in interface java.sql.Statementcurrent - one of the following Statement
constants indicating what should happen to current
ResultSet objects obtained using the method
getResultSetCLOSE_CURRENT_RESULT,
KEEP_CURRENT_RESULT, or
CLOSE_ALL_RESULTS
true if the next result is a
ResultSet object; false if it is an
update count or there are no more results
java.sql.SQLException - if a database access error occursexecute(java.lang.String)
public java.sql.ResultSet getGeneratedKeys()
throws java.sql.SQLException
Statement object. If this
Statement object did not generate any keys, an empty
ResultSet object is returned.
getGeneratedKeys in interface java.sql.StatementResultSet object containing the
auto-generated key(s) generated by the execution of this
Statement object
java.sql.SQLException - if a database access error occurs
public int executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
Statement object should be made available for
retrieval.
executeUpdate in interface java.sql.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_KEYS
INSERT,
UPDATE or DELETE statements, or
0 for SQL statements that return nothing
java.sql.SQLException - if a database access error occurs, the
given SQL statement returns a ResultSet object, or
the given constant is not one of those allowed
public int executeUpdate(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
INSERT statement.
executeUpdate in interface java.sql.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 row
INSERT,
UPDATE, or DELETE statements, or 0 for
SQL statements that return nothing
java.sql.SQLException - if a database access error occurs or the
SQL statement returns a ResultSet object
public int executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
INSERT statement.
executeUpdate in interface java.sql.Statementsql - an SQL INSERT, UPDATE or
DELETE statement or an SQL statement that returns
nothingcolumnNames - an array of the names of the columns that
should be returned from the inserted row
INSERT,
UPDATE, or DELETE statements, or 0 for
SQL statements that return nothing
java.sql.SQLException - if a database access error occurs
public boolean execute(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
INSERT
statement.
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).
execute in interface java.sql.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_KEYS
true if the first result is a
ResultSet object; false if it is an
update count or there are no results
java.sql.SQLException - if a database access error occursgetResultSet(),
getUpdateCount(),
getMoreResults(),
getGeneratedKeys()
public boolean execute(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
INSERT statement.
Under 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).
execute in interface java.sql.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 getGeneratedKeys
true if the first result is a
ResultSet object; false if it is an
update count or there are no results
java.sql.SQLException - if a database access error occursgetResultSet(),
getUpdateCount(),
getMoreResults()
public boolean execute(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
INSERT statement.
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).
execute in interface java.sql.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 getGeneratedKeys
true if the next result is a
ResultSet object; false if it is an
update count or there are no more results
java.sql.SQLException - if a database access error occursgetResultSet(),
getUpdateCount(),
getMoreResults(),
getGeneratedKeys()
public int getResultSetHoldability()
throws java.sql.SQLException
ResultSet
objects generated by this Statement object.
getResultSetHoldability in interface java.sql.StatementResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException - if a database access error occurs
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||