org.objectweb.cjdbc.driver
Class Statement

java.lang.Object
  extended byorg.objectweb.cjdbc.driver.Statement
All Implemented Interfaces:
java.sql.Statement
Direct Known Subclasses:
PreparedStatement

public class Statement
extends java.lang.Object
implements java.sql.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.

Version:
1.0
Author:
Emmanuel Cecchet , Vadim Kassin , Jean-Bernard van Zuylen
See Also:
Statement, DriverResultSet

Field Summary
protected  java.util.Vector batch
          Vector for batch commands
protected  Connection connection
          The connection that created us
private  java.lang.String cursorName
          Cursor name used jointly with fetch size
protected  boolean escapeProcessing
          Should the driver to escape processing before sending to the DB?
private  int fetchDirection
          Direction for fetching rows from ResultSet (note that this hint is currently ignored
private  int fetchSize
          Default ResultSet fetch size
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
protected  java.sql.ResultSet result
          The current result for a read request
private  int resultSetConcurrency
          ResultSet Concurrency defaults to CONCUR_READ_ONLY
private  int resultSetType
          Type of the ResultSet defaults to TYPE_FORWARD_ONLY
private  int timeout
          Query timeout in seconds (0 means no timeout)
protected  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()
           
 int getFetchSize()
           
 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.
private  boolean isClosed()
          Test if this statement is closed.
 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)
           
 void setFetchSize(int rows)
          Set the default fetch size for the produced ResultSet.
 void setMaxFieldSize(int max)
          Sets the maxFieldSize.
 void setMaxRows(int max)
          Sets the maximum number of rows that any ResultSet can contain.
 void setQueryTimeout(int seconds)
          Sets the number of seconds the driver will wait for a Statement object to execute.
 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

connection

protected Connection connection
The connection that created us


batch

protected java.util.Vector batch
Vector for batch commands


warnings

private java.sql.SQLWarning warnings
The warnings chain


result

protected java.sql.ResultSet result
The current result for a read request


updateCount

protected int updateCount
The update count for a write request


timeout

private int timeout
Query timeout in seconds (0 means no timeout)


fetchSize

private int fetchSize
Default ResultSet fetch size


cursorName

private java.lang.String cursorName
Cursor name used jointly with fetch size


resultSetType

private int resultSetType
Type of the ResultSet defaults to TYPE_FORWARD_ONLY


resultSetConcurrency

private int resultSetConcurrency
ResultSet Concurrency defaults to CONCUR_READ_ONLY


maxFieldSize

private int maxFieldSize
Maximum field size (unused)


maxRows

private int maxRows
Maximum number of rows


fetchDirection

private int fetchDirection
Direction for fetching rows from ResultSet (note that this hint is currently ignored


escapeProcessing

protected boolean escapeProcessing
Should the driver to escape processing before sending to the DB?


generatedKeys

protected java.sql.ResultSet generatedKeys
Auto generated keys


generatedKeysFlag

protected int generatedKeysFlag
Constructor Detail

Statement

public Statement(Connection c)
Creates a new Statement instance.

Parameters:
c - the Connection that created us
Method Detail

addBatch

public void addBatch(java.lang.String sql)
              throws java.sql.SQLException
Adds sql to the current list of commands.

Specified by:
addBatch in interface java.sql.Statement
Parameters:
sql - an SQL statement that returns an update count (INSERT or UPDATE)
Throws:
java.sql.SQLException - if an error occurs

cancel

public void cancel()
            throws java.sql.SQLException
Could be use by one thread to cancel a statement that is being executed by another thread. We don't support that for instance.

Specified by:
cancel in interface java.sql.Statement
Throws:
java.sql.SQLException - if an error occurs

clearBatch

public void clearBatch()
                throws java.sql.SQLException
Empties the current list of commands.

Specified by:
clearBatch in interface java.sql.Statement
Throws:
java.sql.SQLException - if an error occurs

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
After this call, getWarnings returns null until a new warning is reported for this Statement.

Specified by:
clearWarnings in interface java.sql.Statement
Throws:
java.sql.SQLException - if a database access error occurs (why?)

executeBatch

public int[] executeBatch()
                   throws java.sql.BatchUpdateException
Execute a batch of commands

Specified by:
executeBatch in interface java.sql.Statement
Returns:
an array containing update count that corresponding to the commands that executed successfully
Throws:
java.sql.BatchUpdateException - if an error occurs on one statement (the number of updated rows for the successfully executed statements can be found in BatchUpdateException.getUpdateCounts())

close

public void close()
           throws java.sql.SQLException
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.

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.

Specified by:
close in interface java.sql.Statement
Throws:
java.sql.SQLException - if a database access error occurs (why?)

execute

public boolean execute(java.lang.String sql)
                throws java.sql.SQLException
Execute a SQL statement that may return multiple results.

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
Returns:
true if the result is a ResultSet or false if it is an integer
Throws:
java.sql.SQLException - if an error occurs

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException
Execute a SQL statement that returns a single ResultSet

Specified by:
executeQuery in interface java.sql.Statement
Parameters:
sql - typically a static SQL SELECT statement
Returns:
a ResulSet that contains the data produced by the query
Throws:
java.sql.SQLException - if a database access error occurs

executeQuery

protected java.sql.ResultSet executeQuery(java.lang.String sqlSkeleton,
                                          java.lang.String sqlQuery)
                                   throws java.sql.SQLException
Execute a SQL statement that returns a single ResultSet

Parameters:
sqlSkeleton - the SQL request squeleton or null
sqlQuery - typically a static SQL SELECT statement that is already trimed
Returns:
a ResulSet that contains the data produced by the query
Throws:
java.sql.SQLException - if a database access error occurs or if this statement is closed

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.sql.SQLException
Execute a SQL INSERT, UPDATE or DELETE statement. In addition SQL statements that return nothing such as SQL DDL statements can be executed

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - a SQL statement
Returns:
either a row count, or 0 for SQL commands
Throws:
java.sql.SQLException - if a database access error occurs

executeUpdateWithSkeleton

protected int executeUpdateWithSkeleton(java.lang.String sqlSkeleton,
                                        java.lang.String sqlQuery)
                                 throws java.sql.SQLException
Execute a SQL INSERT, UPDATE or DELETE statement. In addition SQL statements that return nothing such as SQL DDL statements can be executed

Parameters:
sqlSkeleton - the SQL request squeleton or null
sqlQuery - a static SQL statement that is already trimed
Returns:
either a row count, or 0 for SQL commands
Throws:
java.sql.SQLException - if a database access error occurs or if this statement is closed

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Retrieve the connection that created this Statement object

Specified by:
getConnection in interface java.sql.Statement
Returns:
a java.sql.Connection object
Throws:
java.sql.SQLException - never

getFetchDirection

public int getFetchDirection()
                      throws java.sql.SQLException
Specified by:
getFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getFetchDirection()

getFetchSize

public int getFetchSize()
                 throws java.sql.SQLException
Specified by:
getFetchSize in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.getFetchSize()

getMaxFieldSize

public int getMaxFieldSize()
                    throws java.sql.SQLException
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. If the limit is exceeded, the excess data is silently discarded.

Note: We don't do anything with this value yet.

Specified by:
getMaxFieldSize in interface java.sql.Statement
Returns:
the current max column size limit; zero means unlimited
Throws:
java.sql.SQLException - if a database access error occurs

getMaxRows

public int getMaxRows()
               throws java.sql.SQLException
The maxRows limit is set to limit the number of rows that any ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.

Specified by:
getMaxRows in interface java.sql.Statement
Returns:
the current maximum row limit; zero means unlimited
Throws:
java.sql.SQLException - if a database access error occurs

getMoreResults

public boolean getMoreResults()
                       throws java.sql.SQLException
Multiple results are not suppoted so this method always return false and reset the update count to -1. Any open ResultSet is implicitly closed.

Specified by:
getMoreResults in interface java.sql.Statement
Returns:
false
Throws:
java.sql.SQLException - if an error occurs

getQueryTimeout

public int getQueryTimeout()
                    throws java.sql.SQLException
The queryTimeout limit is the number of seconds the driver will wait for a Statement to execute. If the limit is exceeded, a SQLException is thrown.

Specified by:
getQueryTimeout in interface java.sql.Statement
Returns:
the current query timeout limit in seconds; 0 = unlimited
Throws:
java.sql.SQLException - if a database access error occurs

getResultSet

public java.sql.ResultSet getResultSet()
                                throws java.sql.SQLException
Returns the current result as a ResultSet.

Specified by:
getResultSet in interface java.sql.Statement
Returns:
the current result set; null if there are no more
Throws:
java.sql.SQLException - never

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws java.sql.SQLException
Retrieve the concurrency mode for the ResultSet.

Specified by:
getResultSetConcurrency in interface java.sql.Statement
Returns:
CONCUR_READ_ONLY or CONCUR_UPDATABLE
Throws:
java.sql.SQLException - never

getResultSetType

public int getResultSetType()
                     throws java.sql.SQLException
Retrieve the type of the generated ResultSet.

Specified by:
getResultSetType in interface java.sql.Statement
Returns:
one of TYPE_FORWARD_ONLY or TYPE_SCROLL_INSENSITIVE
Throws:
java.sql.SQLException - never

getUpdateCount

public int getUpdateCount()
                   throws java.sql.SQLException
Returns the current result as an update count, if the result is a ResultSet or there are no more results, -1 is returned. It should only be called once per result.

Specified by:
getUpdateCount in interface java.sql.Statement
Returns:
the current result as an update count.
Throws:
java.sql.SQLException - if a database access error occurs

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
The first warning reported by calls on this Statement is returned. A Statement's execute methods clear its SQLWarning chain. Subsequent 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.

Specified by:
getWarnings in interface java.sql.Statement
Returns:
the first SQLWarning on null
Throws:
java.sql.SQLException - if a database access error occurs

setCursorName

public void setCursorName(java.lang.String name)
                   throws java.sql.SQLException
Defines the SQL cursor name that will be used by subsequent execute methods. This name can then be used in SQL positioned update/delete statements to identify the current row in the ResultSet generated by this statement. If a database doesn't support positioned update/delete, this method is a no-op.

Specified by:
setCursorName in interface java.sql.Statement
Parameters:
name - the new cursor name
Throws:
java.sql.SQLException - not supported

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws java.sql.SQLException
If escape scanning is on (the default), the driver will do escape substitution before sending the SQL to the database.

Specified by:
setEscapeProcessing in interface java.sql.Statement
Parameters:
enable - true to enable; false to disable
Throws:
java.sql.SQLException - if a database access error occurs

setFetchDirection

public void setFetchDirection(int direction)
                       throws java.sql.SQLException
Specified by:
setFetchDirection in interface java.sql.Statement
Throws:
java.sql.SQLException
See Also:
Statement.setFetchDirection(int)

setFetchSize

public void setFetchSize(int rows)
                  throws java.sql.SQLException
Set the default fetch size for the produced ResultSet.

Specified by:
setFetchSize in interface java.sql.Statement
Parameters:
rows - number of rows that should be fetched from the database
Throws:
java.sql.SQLException - if a database access error occurs or the condition 0 <= size <= this.getMaxRows is not satisfied

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws java.sql.SQLException
Sets the maxFieldSize.

Specified by:
setMaxFieldSize in interface java.sql.Statement
Parameters:
max - the new max column size limit; 0 means unlimited
Throws:
java.sql.SQLException - if a database access error occurs or the condition max >= 0 is not satisfied

setMaxRows

public void setMaxRows(int max)
                throws java.sql.SQLException
Sets the maximum number of rows that any ResultSet can contain.

Specified by:
setMaxRows in interface java.sql.Statement
Parameters:
max - the new max rows limit; 0 means unlimited
Throws:
java.sql.SQLException - if a database access error occurs or the condition max >= 0 is not satisfied

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws java.sql.SQLException
Sets the number of seconds the driver will wait for a Statement object to execute.

Specified by:
setQueryTimeout in interface java.sql.Statement
Parameters:
seconds - the new query timeout limit in seconds; 0 means no timeout
Throws:
java.sql.SQLException - if a database access error occurs or the condition seconds >= 0 is not satisfied

setResultSetConcurrency

public void setResultSetConcurrency(int value)
                             throws java.sql.SQLException
Parameters:
value - an int value
Throws:
java.sql.SQLException - if an error occurs

setResultSetType

public void setResultSetType(int value)
                      throws java.sql.SQLException
Parameters:
value - an int value
Throws:
java.sql.SQLException - if an error occurs

getMoreResults

public boolean getMoreResults(int current)
                       throws java.sql.SQLException
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.

There are no more results when the following is true:

 
  
   
    
     
      
        (!getMoreResults() && (getUpdateCount() == -1)
       
      
     
    
   
  
 

Specified by:
getMoreResults in interface java.sql.Statement
Parameters:
current - 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
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4
See Also:
execute(String)

getGeneratedKeys

public java.sql.ResultSet getGeneratedKeys()
                                    throws java.sql.SQLException
Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement object did not generate any keys, an empty ResultSet object is returned.

Specified by:
getGeneratedKeys in interface java.sql.Statement
Returns:
a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int autoGeneratedKeys)
                  throws java.sql.SQLException
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.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - must be an SQL INSERT,UPDATE or DELETE statement or an SQL statement that returns nothing
autoGeneratedKeys - 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
Returns:
either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing
Throws:
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
Since:
JDK 1.4

executeUpdate

public int executeUpdate(java.lang.String sql,
                         int[] columnIndexes)
                  throws java.sql.SQLException
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. The driver will ignore the array if the SQL statement is not an INSERT statement.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL INSERT,UPDATE or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement
columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row
Returns:
either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs or the SQL statement returns a ResultSet object
Since:
JDK 1.4

executeUpdate

public int executeUpdate(java.lang.String sql,
                         java.lang.String[] columnNames)
                  throws java.sql.SQLException
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. The driver will ignore the array if the SQL statement is not an INSERT statement.

Specified by:
executeUpdate in interface java.sql.Statement
Parameters:
sql - an SQL INSERT,UPDATE or DELETE statement or an SQL statement that returns nothing
columnNames - an array of the names of the columns that should be returned from the inserted row
Returns:
either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4

execute

public boolean execute(java.lang.String sql,
                       int autoGeneratedKeys)
                throws java.sql.SQLException
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. The driver will ignore this signal if the SQL statement is not an 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).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
autoGeneratedKeys - 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
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults(), getGeneratedKeys()

execute

public boolean execute(java.lang.String sql,
                       int[] columnIndexes)
                throws java.sql.SQLException
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. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an 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).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
columnIndexes - 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
Returns:
true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults()

execute

public boolean execute(java.lang.String sql,
                       java.lang.String[] columnNames)
                throws java.sql.SQLException
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. This array contains the names of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the given SQL statement is not an 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).

Specified by:
execute in interface java.sql.Statement
Parameters:
sql - any SQL statement
columnNames - 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
Returns:
true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4
See Also:
getResultSet(), getUpdateCount(), getMoreResults(), getGeneratedKeys()

getResultSetHoldability

public int getResultSetHoldability()
                            throws java.sql.SQLException
Retrieves the result set holdability for ResultSet objects generated by this Statement object.

Specified by:
getResultSetHoldability in interface java.sql.Statement
Returns:
either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
java.sql.SQLException - if a database access error occurs
Since:
JDK 1.4

isClosed

private boolean isClosed()
Test if this statement is closed.

Returns:
true if this statement is closed


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.