com.ibm.db
Class StatementResult

java.lang.Object
  |
  +--com.ibm.db.StatementResult
Direct Known Subclasses:
SelectResult

public abstract class StatementResult
extends java.lang.Object
implements java.io.Serializable

StatementResult represents a result set from a executing an SQL statement.

See Also:
Serialized Form

Constructor Summary
StatementResult()
          Constructs a new StatementResult.
 
Method Summary
 void addStatementResultAfterListener(StatementResultAfterListener listener)
          Adds the StatementResultAfterListener.
 void addStatementResultBeforeListener(StatementResultBeforeListener listener)
          Adds the StatementResultBeforeListener.
abstract  void closeResult()
          Closes the result set.
abstract  java.util.Enumeration columnNames()
          Returns an enumeration containing the names of the columns in the result set.
abstract  void deleteRow()
          Deletes a row.
abstract  int getColumnCount()
          Returns the number of columns in the result set.
abstract  java.lang.String getColumnName(int columnNumber)
          Returns the name of the column at the specified index.
abstract  java.lang.Object getColumnValue(int columnNumber)
          Returns the value of the column at the specified index.
abstract  java.lang.Object getColumnValue(java.lang.String columnName)
          Returns the value of the column with the specified name.
abstract  java.lang.String getColumnValueToString(int columnNumber)
          Returns the value of the column at the specified index as a String.
abstract  java.lang.String getColumnValueToString(java.lang.String columnName)
          Returns the value of the column with the specified name as a String.
 java.sql.ResultSetMetaData getJDBCMetaData()
          Returns the java.sql.ResultSetMetaData associated with this StatementResult.
 int getNumRows()
          Returns the number of rows in the result set.
 boolean isOpen()
          Returns true if the result set is open in the database and can be accessed, otherwise returns false.
 void removeStatementResultAfterListener(StatementResultAfterListener listener)
          Removes the StatementResultAfterListener.
 void removeStatementResultBeforeListener(StatementResultBeforeListener listener)
          Removes the StatementResultBeforeListener.
abstract  void restoreRow()
          Restores a row's column values to those last known to be in the database.
abstract  void setColumnValue(int columnNumber, java.lang.Object aValue)
          Sets the value of the column at the specified index to the specified value.
abstract  void setColumnValue(java.lang.String columnName, java.lang.Object aValue)
          Sets the value of the column with the specified name to the specified value.
abstract  void setColumnValueFromString(int columnNumber, java.lang.String stringValue)
          Sets the value of the column at the specified index to the specified value.
abstract  void setColumnValueFromString(java.lang.String columnName, java.lang.String stringValue)
          Sets the value of the column with the specified name to the specified value.
abstract  void updateRow()
          Updates a row.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatementResult

public StatementResult()
Constructs a new StatementResult.
Method Detail

addStatementResultAfterListener

public void addStatementResultAfterListener(StatementResultAfterListener listener)
Adds the StatementResultAfterListener. StatementResultAfter events occur after result set scoped actions have been executed such as newRow and updateRow.
Parameters:
listener - StatementResultAfterListener
See Also:
StatementResultAfterListener, removeStatementResultAfterListener(com.ibm.db.StatementResultAfterListener)

addStatementResultBeforeListener

public void addStatementResultBeforeListener(StatementResultBeforeListener listener)
Adds the StatementResultBeforeListener. StatementResultAfter events occur before result set scoped actions such as newRow and updateRow.
Parameters:
listener - StatementResultBeforeListener
See Also:
StatementResultBeforeListener, removeStatementResultBeforeListener(com.ibm.db.StatementResultBeforeListener)

closeResult

public abstract void closeResult()
                          throws DataException
Closes the result set. JDBC resources associated with the result set are released. After the result set is closed, no more rows can be fetched into it and it cannot be used to update the database.
Throws:
DataException - notOpen - if the statement is not open
DataException - noActiveConnection - if no active connection exists
DataException - sqlException - if an SQLException occurred

columnNames

public abstract java.util.Enumeration columnNames()
                                           throws DataException
Returns an enumeration containing the names of the columns in the result set. See subclasses for implementation.
Returns:
enumeration of column names
Throws:
DataException - - if an error occurs

deleteRow

public abstract void deleteRow()
                        throws DataException
Deletes a row. See subclasses for implementation.
Throws:
DataException - if an error occurred

getColumnCount

public abstract int getColumnCount()
                            throws DataException
Returns the number of columns in the result set. See subclasses for implementation.
Returns:
the number of columns in the result set
Throws:
DataException - - if an error occurs

getColumnName

public abstract java.lang.String getColumnName(int columnNumber)
                                        throws DataException
Returns the name of the column at the specified index. See subclasses for implementation. The index of the first column is 1.
Parameters:
columnNumber - index of the column
Returns:
name of the column
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column index is not defined
DataException - if an error occurred

getColumnValue

public abstract java.lang.Object getColumnValue(int columnNumber)
                                         throws DataException
Returns the value of the column at the specified index. The index of the first column is 1. See subclasses for implementation.
Parameters:
columnNumber - index of the column
Returns:
value of the column
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column index is not defined
DataException - if an error occurred
See Also:
setColumnValue(int, java.lang.Object)

getColumnValue

public abstract java.lang.Object getColumnValue(java.lang.String columnName)
                                         throws DataException
Returns the value of the column with the specified name. See subclasses for implementation.
Parameters:
columnName - name of the column
Returns:
value of the column
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column name is not defined
DataException - if an error occurred
See Also:
setColumnValue(int, java.lang.Object)

getColumnValueToString

public abstract java.lang.String getColumnValueToString(int columnNumber)
                                                 throws DataException
Returns the value of the column at the specified index as a String. The value of the column is converted to a String before it is returned. If the column value is null, a null is returned. The index of the first column is 1. See subclasses for implementation.
Parameters:
columnNumber - index of the column
Returns:
value of the column as a String.
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column index is not defined
DataException - if an error occurred
See Also:
setColumnValueFromString(int, java.lang.String)

getColumnValueToString

public abstract java.lang.String getColumnValueToString(java.lang.String columnName)
                                                 throws DataException
Returns the value of the column with the specified name as a String. The value of the column is converted to a String before it is returned. If the column value is null, a null is returned. See subclasses for implementation.
Parameters:
columnName - name of the column
Returns:
value of the column as a String.
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column name is not defined
DataException - if an error occurred
See Also:
setColumnValueFromString(int, java.lang.String)

getJDBCMetaData

public java.sql.ResultSetMetaData getJDBCMetaData()
                                           throws DataException
Returns the java.sql.ResultSetMetaData associated with this StatementResult. If the SQL statement has not been exeucted yet, it will return a null value.
Returns:
the associated ResultSetMetaData
Throws:
DataException - sqlException - if an SQLException occurred

getNumRows

public int getNumRows()
Returns the number of rows in the result set. This number changes as rows are fetched from the database, deleted, or added via the newRow method.
Returns:
number of rows in the result set

isOpen

public boolean isOpen()
Returns true if the result set is open in the database and can be accessed, otherwise returns false. If the result set is not open, no more rows can be fetched into the result set from the database. When isOpen returns false, it may be because the associated Statement has not been executed, the close method has been invoked, or the StatementResult has been serialized and then de-serialized.
Returns:
true if the result set is open in the database, otherwise false.

removeStatementResultAfterListener

public void removeStatementResultAfterListener(StatementResultAfterListener listener)
Removes the StatementResultAfterListener. StatementResultAfter events occur after result set scoped actions have been executed such as newRow and updateRow.
Parameters:
listener - StatementResultAfterListener
See Also:
StatementResultAfterListener, addStatementResultAfterListener(com.ibm.db.StatementResultAfterListener)

removeStatementResultBeforeListener

public void removeStatementResultBeforeListener(StatementResultBeforeListener listener)
Removes the StatementResultBeforeListener. StatementResultAfter events occur before result set scoped actions have been executed such as newRow and updateRow.
Parameters:
listener - StatementResultBeforeListener
See Also:
StatementResultBeforeListener, addStatementResultBeforeListener(com.ibm.db.StatementResultBeforeListener)

restoreRow

public abstract void restoreRow()
                         throws DataException
Restores a row's column values to those last known to be in the database. See subclasses for implementation.
Throws:
DataException - if an error occurred

setColumnValue

public abstract void setColumnValue(int columnNumber,
                                    java.lang.Object aValue)
                             throws DataException
Sets the value of the column at the specified index to the specified value. The index of the first column is 1. See subclasses for implementation.
Parameters:
columnNumber - index of the column
aValue - value for the column
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column index is not defined
DataException - if an error occurred
See Also:
getColumnValue(int)

setColumnValue

public abstract void setColumnValue(java.lang.String columnName,
                                    java.lang.Object aValue)
                             throws DataException
Sets the value of the column with the specified name to the specified value. See subclasses for implementation.
Parameters:
columnName - name of the column
aValue - value for the column
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column name is not defined
DataException - if an error occurred
See Also:
getColumnValue(int)

setColumnValueFromString

public abstract void setColumnValueFromString(int columnNumber,
                                              java.lang.String stringValue)
                                       throws DataException
Sets the value of the column at the specified index to the specified value. The stringValue parameter is converted to the datatype associated with the column before the value is set. The index of the first column is 1. See subclasses for implementation.
Parameters:
columnNumber - index of the column
stringValue - value for the column as a String
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column index is not defined
DataException - if an error occurred
See Also:
getColumnValueToString(int)

setColumnValueFromString

public abstract void setColumnValueFromString(java.lang.String columnName,
                                              java.lang.String stringValue)
                                       throws DataException
Sets the value of the column with the specified name to the specified value. The stringValue parameter is converted to the datatype associated with the column before the value is set. See subclasses for implementation.
Parameters:
columnName - name of the column
stringValue - value for the column as a String
Throws:
java.lang.IndexOutOfBoundsException - noSuchColumn - if the column name is not defined
DataException - if an error occurred
See Also:
getColumnValueToString(int)

updateRow

public abstract void updateRow()
                        throws DataException
Updates a row. See subclasses for implementation.
Throws:
DataException - if an error occurred