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

Field Summary
protected  StatementResultAfterListener aStatementResultAfterListener
           
protected  StatementResultBeforeListener aStatementResultBeforeListener
           
private static java.lang.String copyright
           
protected  int fieldNumRows
           
protected  DatabaseResultTableParent rt
           
(package private) static long serialVersionUID
           
 
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.
protected  void finalize()
          Code to perform when this object is garbage collected.
protected  void fireAboutToAddNewRow(DataEvent event)
          Method to support listener events.
protected  void fireAboutToClose(DataEvent event)
          Method to support listener events.
protected  void fireAboutToDeleteRow(DataEvent event)
          Method to support listener events.
protected  void fireAboutToUpdateRow(DataEvent event)
          Method to support listener events.
protected  void fireAddedNewRow(DataEvent event)
          Method to support listener events.
protected  void fireClosed(DataEvent event)
          Method to support listener events.
protected  void fireDeletedRow(DataEvent event)
          Method to support listener events.
protected  void fireUpdatedRow(DataEvent event)
          Method to support listener events.
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.
protected  DatabaseResultTableParent getResultTable()
          Returns the DatabaseResultTable associated with the StatementResult.
protected static void handleSQLException(java.sql.SQLException ex)
          This method was created by a SmartGuide.
protected abstract  void initialize()
          Initializes the StatementResult.
 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.
protected  void setResultTable(DatabaseResultTable resultTable)
          This method was created in VisualAge.
protected  void setResultTable(DatabaseResultTableParent resultTable)
          This method was created in VisualAge.
abstract  void updateRow()
          Updates a row.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

fieldNumRows

protected int fieldNumRows

rt

protected transient DatabaseResultTableParent rt

aStatementResultBeforeListener

protected transient StatementResultBeforeListener aStatementResultBeforeListener

aStatementResultAfterListener

protected transient StatementResultAfterListener aStatementResultAfterListener

serialVersionUID

static final long serialVersionUID

copyright

private static final java.lang.String copyright
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

finalize

protected void finalize()
                 throws java.lang.Throwable
Code to perform when this object is garbage collected. Any exception thrown by a finalize method causes the finalization to halt. But otherwise, it is ignored.
Overrides:
finalize in class java.lang.Object

fireAboutToAddNewRow

protected void fireAboutToAddNewRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireAboutToClose

protected void fireAboutToClose(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireAboutToDeleteRow

protected void fireAboutToDeleteRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireAboutToUpdateRow

protected void fireAboutToUpdateRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireAddedNewRow

protected void fireAddedNewRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireClosed

protected void fireClosed(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireDeletedRow

protected void fireDeletedRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

fireUpdatedRow

protected void fireUpdatedRow(DataEvent event)
Method to support listener events.
Parameters:
event - DataEvent

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
See Also:
setColumnValueFromString(int, java.lang.String)

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

getResultTable

protected DatabaseResultTableParent getResultTable()
Returns the DatabaseResultTable associated with the StatementResult.
Returns:
the associated DatabaseResultTable
See Also:
DatabaseResultTable

handleSQLException

protected static void handleSQLException(java.sql.SQLException ex)
                                  throws DataException
This method was created by a SmartGuide.
Throws:
DataException - The exception description.

initialize

protected abstract void initialize()
                            throws DataException
Initializes the StatementResult. See subclasses for implementation.
Throws:
DataException - if an error occurred

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)

setResultTable

protected void setResultTable(DatabaseResultTable resultTable)
This method was created in VisualAge.
Parameters:
resultTable - com.ibm.db.base.DatabaseResultTable

setResultTable

protected void setResultTable(DatabaseResultTableParent resultTable)
This method was created in VisualAge.
Parameters:
resultTable - com.ibm.db.base.DatabaseResultTable

updateRow

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