superwaba.ext.xplat.sql.db2e
Class Db2eStatement

java.lang.Object
  |
  +--superwaba.ext.xplat.sql.Statement
        |
        +--superwaba.ext.xplat.sql.PreparedStatement
              |
              +--superwaba.ext.xplat.sql.db2e.Db2eStatement

public class Db2eStatement
extends PreparedStatement

This implements Statement and PreparedStatement to save on overall package size.


Field Summary
protected  int _conHandle
           
protected  Db2eConnection _connection
           
protected  int _count
           
protected  Db2e _db
           
protected  int _maxFieldSize
           
protected  superwaba.ext.xplat.sql.db2e.Db2eResultSet.Db2eRsmd _meta
           
protected  boolean _resultOpen
           
protected  superwaba.ext.xplat.sql.db2e.Db2eResultSet _results
           
protected  int _resultSetType
           
protected  int _statement
           
protected  SQLWarning _warnings
           
 
Fields inherited from class superwaba.ext.xplat.sql.Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO
 
Method Summary
 void addBatch()
          This method adds a set of parameters to the batch for JDBC 2.0.
 void addBatch(String sql)
          This method adds a SQL statement to a SQL batch.
 void clearBatch()
          This method clears out any SQL statements that have been populated in the current batch.
 void clearParameters()
          This method clears all of the input parameter that have been set on this statement.
 void clearWarnings()
          This method clears any SQL warnings that have been attached to this statement.
 void close()
          This method closes the statement and frees any associated resources.
protected  void ensureParamSize(int parameterIndex)
           
 boolean execute()
          This method executes a prepared SQL query.
 boolean execute(String sql)
          This method executes an arbitrary SQL statement of any time.
 int[] executeBatch()
          This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch.
 ResultSet executeQuery()
          This method executes a prepared SQL query and returns its ResultSet.
 ResultSet executeQuery(String sql)
          This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.
protected  boolean executeSet(String sql)
           
 int executeUpdate()
          This method executes an SQL INSERT, UPDATE or DELETE statement.
 int executeUpdate(String sql)
          This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.
 Connection getConnection()
          This method returns the Connection instance that was used to create this object.
 int getFetchDirection()
          This method returns the current direction that the driver thinks the result set will be accessed int.
 int getFetchSize()
          This method returns the number of rows the driver believes should be fetched from the database at a time.
 int getMaxFieldSize()
          This method returns the maximum length of any column value in bytes.
 int getMaxRows()
          This method returns the maximum possible number of rows in a result set.
 ResultSetMetaData getMetaData()
          This method returns meta data for the result set from this statement.
 boolean getMoreResults()
          This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet
 ParameterMetaData getParameterMetaData()
           
 int getQueryTimeout()
          The method returns the number of seconds a statement may be in process before timing out.
 ResultSet getResultSet()
          This method returns the result set of the SQL statement that was executed.
 int getResultSetConcurrency()
          This method returns the concurrency type of the result set for this statement.
 int getResultSetType()
          This method returns the result set type for this statement.
 int getUpdateCount()
          This method returns the update count of the SQL statement that was executed.
 SQLWarning getWarnings()
          This method returns the first SQL warning attached to this statement.
protected  void handleError(DB2Exception error)
           
protected  void notSupported()
           
protected  boolean prepResultSet(boolean resetColumns)
           
 void setBlob(int parameterIndex, Blob x)
          This method sets the specified parameter from the given Java Blob value.
 void setBoolean(int parameterIndex, boolean x)
          This method sets the specified parameter from the given Java boolean value.
 void setByte(int parameterIndex, byte x)
          This method sets the specified parameter from the given Java byte value.
 void setBytes(int parameterIndex, byte[] x)
          This method sets the specified parameter from the given Java byte array value.
 void setBytes(int parameterIndex, byte[] x, int start, int length)
          This method sets the specified parameter from the given Java byte array value.
 void setCursorName(String name)
          This method sets the cursor name that will be used by the result set.
 void setDate(int parameterIndex, Date x)
          This method sets the specified parameter from the given Java java.sql.Date value.
 void setDouble(int parameterIndex, double x)
          This method sets the specified parameter from the given Java double value.
 void setEscapeProcessing(boolean enable)
          This method sets the local escape processing mode on or off.
 void setFetchDirection(int direction)
          This method informs the driver which direction the result set will be accessed in.
 void setFetchSize(int rows)
          This method informs the driver how many rows it should fetch from the database at a time.
 void setFloat(int parameterIndex, float x)
          This method sets the specified parameter from the given Java float value.
 void setInt(int parameterIndex, int x)
          This method sets the specified parameter from the given Java int value.
 void setLong(int parameterIndex, long x)
          This method sets the specified parameter from the given Java long value.
 void setMaxFieldSize(int max)
          This method sets the limit for the maximum length of any column in bytes.
 void setMaxRows(int max)
          This method sets the maximum number of rows that can be present in a result set.
 void setNull(int parameterIndex, int sqlType)
          This method populates the specified parameter with a SQL NULL value for the specified type.
 void setNull(int paramIndex, int sqlType, String typeName)
          This method populates the specified parameter with a SQL NULL value for the specified type.
 void setObject(int parameterIndex, Object x)
          This method sets the specified parameter from the given Java Object value.
 void setObject(int parameterIndex, Object x, int targetSqlType)
          This method sets the specified parameter from the given Java Object value.
 void setObject(int parameterIndex, Object x, int targetSqlType, int scale)
          This method sets the specified parameter from the given Java Object value.
 void setQueryTimeout(int seconds)
          This method sets the number of seconds a statement may be in process before timing out.
 void setRef(int i, Ref x)
          This method sets the specified parameter from the given Java Ref value.
 void setShort(int parameterIndex, short x)
          This method sets the specified parameter from the given Java short value.
 void setString(int parameterIndex, String x)
          This method sets the specified parameter from the given Java String value.
 void setTime(int parameterIndex, Time x)
          This method sets the specified parameter from the given Java java.sql.Time value.
 void setTimestamp(int parameterIndex, Timestamp x)
          This method sets the specified parameter from the given Java java.sql.Timestamp value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, toString, wait, wait
 

Field Detail

_warnings

protected SQLWarning _warnings

_connection

protected Db2eConnection _connection

_db

protected Db2e _db

_conHandle

protected int _conHandle

_statement

protected int _statement

_maxFieldSize

protected int _maxFieldSize

_resultOpen

protected boolean _resultOpen

_results

protected superwaba.ext.xplat.sql.db2e.Db2eResultSet _results

_meta

protected superwaba.ext.xplat.sql.db2e.Db2eResultSet.Db2eRsmd _meta

_count

protected int _count

_resultSetType

protected int _resultSetType
Method Detail

notSupported

protected void notSupported()
                     throws SQLException

handleError

protected void handleError(DB2Exception error)
                    throws SQLException

prepResultSet

protected boolean prepResultSet(boolean resetColumns)
                         throws SQLException

addBatch

public void addBatch(String sql)
              throws SQLException
This method adds a SQL statement to a SQL batch. A driver is not required to implement this method.
Overrides:
addBatch in class Statement
Parameters:
sql - The sql statement to add to the batch.
Throws:
SQLException - If an error occurs.

clearBatch

public void clearBatch()
                throws SQLException
This method clears out any SQL statements that have been populated in the current batch. A driver is not required to implement this method.
Overrides:
clearBatch in class Statement
Throws:
SQLException - If an error occurs.

clearWarnings

public void clearWarnings()
                   throws SQLException
This method clears any SQL warnings that have been attached to this statement.
Overrides:
clearWarnings in class Statement
Throws:
SQLException - If an error occurs.

close

public void close()
           throws SQLException
This method closes the statement and frees any associated resources.
Overrides:
close in class Statement
Throws:
SQLException - If an error occurs.

executeSet

protected boolean executeSet(String sql)
                      throws DB2Exception

execute

public boolean execute(String sql)
                throws SQLException
This method executes an arbitrary SQL statement of any time. The methods getResultSet, getMoreResults and getUpdateCount retrieve the results.
Overrides:
execute in class Statement
Returns:
true if a result set was returned, false if an update count was returned.
Throws:
SQLException - If an error occurs.

executeBatch

public int[] executeBatch()
                   throws SQLException
This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch. A driver is not required to implement this method.
Overrides:
executeBatch in class Statement
Returns:
An array of update counts for this batch.
Throws:
SQLException - If an error occurs.

executeQuery

public ResultSet executeQuery(String sql)
                       throws SQLException
This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query.
Overrides:
executeQuery in class Statement
Parameters:
sql - The SQL statement to execute.
Returns:
The result set of the SQL statement.
Throws:
SQLException - If an error occurs.

executeUpdate

public int executeUpdate(String sql)
                  throws SQLException
This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0.
Overrides:
executeUpdate in class Statement
Parameters:
sql - The SQL statement to execute.
Returns:
The number of rows affected by the SQL statement.
Throws:
SQLException - If an error occurs.

getConnection

public Connection getConnection()
                         throws SQLException
This method returns the Connection instance that was used to create this object.
Overrides:
getConnection in class Statement
Returns:
The connection used to create this object.
Throws:
SQLException - If an error occurs.

getFetchDirection

public int getFetchDirection()
                      throws SQLException
This method returns the current direction that the driver thinks the result set will be accessed int.
Overrides:
getFetchDirection in class Statement
Returns:
The direction the result set will be accessed in (????)
Throws:
SQLException - If an error occurs.

getFetchSize

public int getFetchSize()
                 throws SQLException
This method returns the number of rows the driver believes should be fetched from the database at a time.
Overrides:
getFetchSize in class Statement
Returns:
The number of rows that will be fetched from the database at a time.
Throws:
SQLException - If an error occurs.

getMaxFieldSize

public int getMaxFieldSize()
                    throws SQLException
This method returns the maximum length of any column value in bytes.
Overrides:
getMaxFieldSize in class Statement
Returns:
The maximum length of any column value in bytes.
Throws:
SQLException - If an error occurs.

getMaxRows

public int getMaxRows()
               throws SQLException
This method returns the maximum possible number of rows in a result set.
Overrides:
getMaxRows in class Statement
Returns:
The maximum possible number of rows in a result set.
Throws:
SQLException - If an error occurs.

getMoreResults

public boolean getMoreResults()
                       throws SQLException
This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet
Overrides:
getMoreResults in class Statement
Returns:
true if there is another result set, false otherwise (for example, the next result is an update count).
Throws:
SQLException - If an error occurs.
See Also:
execute(java.lang.String)

getQueryTimeout

public int getQueryTimeout()
                    throws SQLException
The method returns the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.
Overrides:
getQueryTimeout in class Statement
Returns:
The SQL statement timeout in seconds.
Throws:
SQLException - If an error occurs.

getResultSet

public ResultSet getResultSet()
                       throws SQLException
This method returns the result set of the SQL statement that was executed. This should be called only once per result set returned.
Overrides:
getResultSet in class Statement
Returns:
The result set of the query, or null if there was no result set (for example, if the statement was an UPDATE).
Throws:
SQLException - If an error occurs.
See Also:
execute(java.lang.String)

getResultSetConcurrency

public int getResultSetConcurrency()
                            throws SQLException
This method returns the concurrency type of the result set for this statement. This will be one of the concurrency types defined in ResultSet.
Overrides:
getResultSetConcurrency in class Statement
Returns:
The concurrency type of the result set for this statement.
Throws:
SQLException - If an error occurs.
See Also:
ResultSet

getResultSetType

public int getResultSetType()
                     throws SQLException
This method returns the result set type for this statement. This will be one of the result set types defined in ResultSet.
Overrides:
getResultSetType in class Statement
Returns:
The result set type for this statement.
Throws:
SQLException - If an error occurs.
See Also:
ResultSet

getUpdateCount

public int getUpdateCount()
                   throws SQLException
This method returns the update count of the SQL statement that was executed. This should be called only once per executed SQL statement.
Overrides:
getUpdateCount in class Statement
Returns:
The update count of the query, or -1 if there was no update count (for example, if the statement was a SELECT).
Throws:
SQLException - If an error occurs.
See Also:
execute(java.lang.String)

getWarnings

public SQLWarning getWarnings()
                       throws SQLException
This method returns the first SQL warning attached to this statement. Subsequent warnings will be chained to this one.
Overrides:
getWarnings in class Statement
Returns:
The first SQL warning for this statement.
Throws:
SQLException - If an error occurs.

setCursorName

public void setCursorName(String name)
                   throws SQLException
This method sets the cursor name that will be used by the result set.
Overrides:
setCursorName in class Statement
Parameters:
name - The cursor name to use for this statement.
Throws:
SQLException - If an error occurs.

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
                         throws SQLException
This method sets the local escape processing mode on or off. The default value is on.
Overrides:
setEscapeProcessing in class Statement
Parameters:
escape - true to enable local escape processing, false to disable it.
Throws:
SQLException - If an error occurs.

setFetchDirection

public void setFetchDirection(int direction)
                       throws SQLException
This method informs the driver which direction the result set will be accessed in.
Overrides:
setFetchDirection in class Statement
Parameters:
direction - The direction the result set will be accessed in (?????)
Throws:
SQLException - If an error occurs.

setFetchSize

public void setFetchSize(int rows)
                  throws SQLException
This method informs the driver how many rows it should fetch from the database at a time.
Overrides:
setFetchSize in class Statement
Parameters:
numrows - The number of rows the driver should fetch at a time to populate the result set.
Throws:
SQLException - If an error occurs.

setMaxFieldSize

public void setMaxFieldSize(int max)
                     throws SQLException
This method sets the limit for the maximum length of any column in bytes.
Overrides:
setMaxFieldSize in class Statement
Parameters:
maxsize - The new maximum length of any column in bytes.
Throws:
SQLException - If an error occurs.

setMaxRows

public void setMaxRows(int max)
                throws SQLException
This method sets the maximum number of rows that can be present in a result set.
Overrides:
setMaxRows in class Statement
Parameters:
maxrows - The maximum possible number of rows in a result set.
Throws:
SQLException - If an error occurs.

setQueryTimeout

public void setQueryTimeout(int seconds)
                     throws SQLException
This method sets the number of seconds a statement may be in process before timing out. A value of 0 means there is no timeout.
Overrides:
setQueryTimeout in class Statement
Parameters:
timeout - The new SQL statement timeout value.
Throws:
SQLException - If an error occurs.

addBatch

public void addBatch()
              throws SQLException
This method adds a set of parameters to the batch for JDBC 2.0.
Overrides:
addBatch in class PreparedStatement
Throws:
SQLException - If an error occurs.

clearParameters

public void clearParameters()
                     throws SQLException
This method clears all of the input parameter that have been set on this statement.
Overrides:
clearParameters in class PreparedStatement
Throws:
SQLException - If an error occurs.

execute

public boolean execute()
                throws SQLException
This method executes a prepared SQL query. Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by executeQuery and executeUpdate.
Overrides:
execute in class PreparedStatement
Returns:
The result of the SQL statement.
Throws:
SQLException - If an error occurs.

executeQuery

public ResultSet executeQuery()
                       throws SQLException
This method executes a prepared SQL query and returns its ResultSet.
Overrides:
executeQuery in class PreparedStatement
Returns:
The ResultSet of the SQL statement.
Throws:
SQLException - If an error occurs.

executeUpdate

public int executeUpdate()
                  throws SQLException
This method executes an SQL INSERT, UPDATE or DELETE statement. SQL statements that return nothing such as SQL DDL statements can be executed.
Overrides:
executeUpdate in class PreparedStatement
Returns:
The result is either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing.
Throws:
SQLException - If an error occurs.

getMetaData

public ResultSetMetaData getMetaData()
                              throws SQLException
This method returns meta data for the result set from this statement.
Overrides:
getMetaData in class PreparedStatement
Returns:
Meta data for the result set from this statement.
Throws:
SQLException - If an error occurs.

getParameterMetaData

public ParameterMetaData getParameterMetaData()
                                       throws SQLException
Overrides:
getParameterMetaData in class PreparedStatement
Since:
1.4

ensureParamSize

protected void ensureParamSize(int parameterIndex)

setBlob

public void setBlob(int parameterIndex,
                    Blob x)
             throws SQLException
This method sets the specified parameter from the given Java Blob value. The default object type to SQL type mapping will be used.
Overrides:
setBlob in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setBoolean

public void setBoolean(int parameterIndex,
                       boolean x)
                throws SQLException
This method sets the specified parameter from the given Java boolean value.
Overrides:
setBoolean in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setByte

public void setByte(int parameterIndex,
                    byte x)
             throws SQLException
This method sets the specified parameter from the given Java byte value.
Overrides:
setByte in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setBytes

public void setBytes(int parameterIndex,
                     byte[] x)
              throws SQLException
This method sets the specified parameter from the given Java byte array value.
Overrides:
setBytes in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setBytes

public void setBytes(int parameterIndex,
                     byte[] x,
                     int start,
                     int length)
              throws SQLException
This method sets the specified parameter from the given Java byte array value.
Overrides:
setBytes in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setDate

public void setDate(int parameterIndex,
                    Date x)
             throws SQLException
This method sets the specified parameter from the given Java java.sql.Date value.
Overrides:
setDate in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setDouble

public void setDouble(int parameterIndex,
                      double x)
               throws SQLException
This method sets the specified parameter from the given Java double value.
Overrides:
setDouble in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setFloat

public void setFloat(int parameterIndex,
                     float x)
              throws SQLException
This method sets the specified parameter from the given Java float value.
Overrides:
setFloat in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setInt

public void setInt(int parameterIndex,
                   int x)
            throws SQLException
This method sets the specified parameter from the given Java int value.
Overrides:
setInt in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setLong

public void setLong(int parameterIndex,
                    long x)
             throws SQLException
This method sets the specified parameter from the given Java long value.
Overrides:
setLong in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setNull

public void setNull(int parameterIndex,
                    int sqlType)
             throws SQLException
This method populates the specified parameter with a SQL NULL value for the specified type.
Overrides:
setNull in class PreparedStatement
Parameters:
index - The index of the parameter to set.
type - The SQL type identifier of the parameter from Types
Throws:
SQLException - If an error occurs.

setNull

public void setNull(int paramIndex,
                    int sqlType,
                    String typeName)
             throws SQLException
This method populates the specified parameter with a SQL NULL value for the specified type.
Overrides:
setNull in class PreparedStatement
Parameters:
index - The index of the parameter to set.
type - The SQL type identifier of the parameter from Types
name - The name of the data type, for user defined types.
Throws:
SQLException - If an error occurs.

setObject

public void setObject(int parameterIndex,
                      Object x)
               throws SQLException
This method sets the specified parameter from the given Java Object value. The default object type to SQL type mapping will be used.
Overrides:
setObject in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setObject

public void setObject(int parameterIndex,
                      Object x,
                      int targetSqlType)
               throws SQLException
This method sets the specified parameter from the given Java Object value. The specified SQL object type will be used.
Overrides:
setObject in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
type - The SQL type to use for the parameter, from Types
Throws:
SQLException - If an error occurs.
See Also:
Types

setObject

public void setObject(int parameterIndex,
                      Object x,
                      int targetSqlType,
                      int scale)
               throws SQLException
This method sets the specified parameter from the given Java Object value. The specified SQL object type will be used.
Overrides:
setObject in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
type - The SQL type to use for the parameter, from Types
scale - The scale of the value, for numeric values only.
Throws:
SQLException - If an error occurs.
See Also:
Types

setRef

public void setRef(int i,
                   Ref x)
            throws SQLException
This method sets the specified parameter from the given Java Ref value. The default object type to SQL type mapping will be used.
Overrides:
setRef in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setShort

public void setShort(int parameterIndex,
                     short x)
              throws SQLException
This method sets the specified parameter from the given Java short value.
Overrides:
setShort in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setString

public void setString(int parameterIndex,
                      String x)
               throws SQLException
This method sets the specified parameter from the given Java String value.
Overrides:
setString in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setTime

public void setTime(int parameterIndex,
                    Time x)
             throws SQLException
This method sets the specified parameter from the given Java java.sql.Time value.
Overrides:
setTime in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.

setTimestamp

public void setTimestamp(int parameterIndex,
                         Timestamp x)
                  throws SQLException
This method sets the specified parameter from the given Java java.sql.Timestamp value.
Overrides:
setTimestamp in class PreparedStatement
Parameters:
index - The index of the parameter value to set.
value - The value of the parameter.
Throws:
SQLException - If an error occurs.