|
2.50.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--interbase.interclient.Statement
A SQL container used for executing SQL, and a factory for result sets.
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 statement execute methods implicitly close a statement's current ResultSet if an open one exists.
Connection.createStatement()
,
ResultSet
Method Summary | |
void |
addBatch(String sql)
Adds a SQL command to the current batch of commmands for the statement. |
void |
cancel()
Cancel can be used by one thread to cancel a statement that is being executed by another thread. |
void |
clearBatch()
Make the set of commands in the current batch empty. |
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; the close method provides this immediate release. |
boolean |
execute(String sql)
Execute a SQL statement that may return multiple results. |
int[] |
executeBatch()
Submit a batch of commands to the database for execution. |
ResultSet |
executeQuery(String sql)
Execute a SQL statement that returns a single ResultSet. |
int |
executeUpdate(String sql)
Execute a SQL INSERT, UPDATE or DELETE statement. |
protected void |
finalize()
A statement will be closed when its finalizer is called by the garbage collector. |
Connection |
getConnection()
Returns the Connection that produced this Statement. |
int |
getFetchDirection()
Determine the fetch direction. |
int |
getFetchSize()
Determine the default fetch size. |
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 the maximum number of rows that a ResultSet can contain. |
boolean |
getMoreResults()
getMoreResults moves to a Statement's next result. |
int |
getQueryTimeout()
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. |
ResultSet |
getResultSet()
getResultSet returns the current result as a ResultSet. |
int |
getResultSetConcurrency()
Determine the result set concurrency. |
int |
getResultSetType()
Determine the result set type. |
int |
getUpdateCount()
getUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results, -1 is returned. |
SQLWarning |
getWarnings()
The first warning reported by calls on this Statement is returned. |
void |
setCursorName(String cursorName)
setCursorname defines the SQL cursor name that will be used by subsequent Statement 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)
Give a hint as to the direction in which the rows in a result set will be processed. |
void |
setFetchSize(int rows)
Give 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 maxFieldSize)
The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. |
void |
setMaxRows(int maxRows)
The maxRows limit is set to limit the number of rows that any ResultSet can contain. |
void |
setQueryTimeout(int seconds)
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
protected void finalize() throws Throwable
Therefore, it is recommended that prepared statements be explicitly closed even if your application throws an exception. This can be achieved by placing a call to close() in a finally clause of your application as follows
try { ... } finally { if (statement != null) try { statement.close (); } catch (SQLException e) {} if (connection != null) try { connection.close (); } catch (SQLException e) {} }
Or alternatively, use the System.runFinalizersOnExit () method.
finalize
in class Object
public ResultSet executeQuery(String sql) throws SQLException
executeQuery
in interface Statement
sql
- typically this is a static SQL SELECT statementSQLException
- if a database access error occurs.public int executeUpdate(String sql) throws SQLException
executeUpdate
in interface Statement
sql
- a SQL INSERT, UPDATE or DELETE statement or a SQL
statement that returns nothingSQLException
- if a database access error occurs.public void close() throws 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 Statement
SQLException
- if a database access error occurs.public int getMaxFieldSize() throws SQLException
getMaxFieldSize
in interface Statement
SQLException
- if a database access error occurs.public void setMaxFieldSize(int maxFieldSize) throws SQLException
setMaxFieldSize
in interface Statement
max
- the new max column size limit; zero means unlimitedSQLException
- if a database access error occurs.public int getMaxRows() throws SQLException
getMaxRows
in interface Statement
SQLException
- if a database access error occurs.public void setMaxRows(int maxRows) throws SQLException
setMaxRows
in interface Statement
max
- the new max rows limit; zero means unlimitedSQLException
- if a database access error occurs.public void setEscapeProcessing(boolean enable) throws SQLException
setEscapeProcessing
in interface Statement
enable
- true to enable; false to disableSQLException
- if a database access error occurs.public int getQueryTimeout() throws SQLException
getQueryTimeout
in interface Statement
SQLException
- if a database access error occurs.public void setQueryTimeout(int seconds) throws SQLException
InterClient note: Throws DriverNotCapableException. InterBase does not support asynchronous query timeout.
setQueryTimeout
in interface Statement
seconds
- the new query timeout limit in seconds; zero means unlimitedSQLException
- if a database access error occurs.public void cancel() throws SQLException
InterClient note:
cancel
in interface Statement
SQLException
- if a database access error occurs,
if the statement is not open or the statement is not executing.public SQLWarning getWarnings() throws SQLException
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 Statement
SQLException
- if a database access error occurs.public void clearWarnings() throws SQLException
clearWarnings
in interface Statement
SQLException
- if a database access error occurs.public void setCursorName(String cursorName) throws SQLException
Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
setCursorName
in interface Statement
name
- the new cursor name.SQLException
- if a database access error occurs.public boolean execute(String sql) throws SQLException
execute
in interface Statement
sql
- any SQL statementSQLException
- if a database access error occurs.getResultSet()
,
getUpdateCount()
,
getMoreResults()
public ResultSet getResultSet() throws SQLException
getResultSet
in interface Statement
SQLException
- if a database access error occurs.execute(java.lang.String)
public int getUpdateCount() throws SQLException
getUpdateCount
in interface Statement
SQLException
- if a database access error occurs.execute(java.lang.String)
public boolean getMoreResults() throws SQLException
getMoreResults
in interface Statement
SQLException
- if a database access error occurs.execute(java.lang.String)
public void setFetchDirection(int direction) throws SQLException
setFetchDirection
in interface Statement
direction
- the initial direction for processing rowsSQLException
- if a database access error occurs or direction
is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or
ResultSet.FETCH_UNKNOWNpublic int getFetchDirection() throws SQLException
getFetchDirection
in interface Statement
SQLException
- if a database access error occurs.public void setFetchSize(int rows) throws SQLException
InterClient note: The default of zero lets the driver decide. By default, InterClient prefetches as many rows as can fill up a 128K buffer.
setFetchSize
in interface Statement
rows
- the number of rows to fetchSQLException
- if a database access error occurs, or the
condition 0 <= rows <= this.getMaxRows() is not satisfied.public int getFetchSize() throws SQLException
getFetchSize
in interface Statement
SQLException
- if a database access error occurs.public int getResultSetConcurrency() throws SQLException
getResultSetConcurrency
in interface Statement
SQLException
- if a database access error occurs.public int getResultSetType() throws SQLException
getResultSetType
in interface Statement
SQLException
- if a database access error occurs.public void addBatch(String sql) throws SQLException
addBatch
in interface Statement
sql
- typically this is a static SQL INSERT or UPDATE statementSQLException
- if a database access error occurs, or the
driver does not support batch statementspublic void clearBatch() throws SQLException
clearBatch
in interface Statement
SQLException
- if a database access error occurs, or the
driver does not support batch statementspublic int[] executeBatch() throws SQLException
executeBatch
in interface Statement
SQLException
- if a database access error occurs, or the
driver does not support batch statementspublic Connection getConnection() throws SQLException
getConnection
in interface Statement
SQLException
- if a database access error occurs.
|
2.50.5 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |