Class com.ibm.ivj.db.uibeans.Select
java.lang.Object
|
+----com.ibm.ivj.db.uibeans.Statement
|
+----com.ibm.ivj.db.uibeans.Select
- public class Select
- extends Statement
- implements PropertyChangeListener, StatementAfterListener, StatementBeforeListener, DatabaseConnectionAfterListener, DatabaseConnectionBeforeListener, StatementResultAfterListener, StatementResultBeforeListener, StatementResultValueChangeListener, Serializable
Select allows you to access and change data in a relational database using
JDBC.
- Version:
- 1.0 06/30/98
Constructor Index
- Select()
- Constructs a new Select and initializes properties to the default values.
Method Index
- aboutToAddNewRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToAddNewRow
is triggerd and fires the corresponding DataBefore event
aboutToAddNewRow
.
- aboutToClose(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToClose
is triggerd and fires the corresponding DataBefore event
aboutToClose
.
- aboutToCommit(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToCommit
is triggerd and fires the corresponding DataBefore event
aboutToCommit
.
- aboutToConnect(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToConnect
is triggerd and fires the corresponding DataBefore event
aboutToConnect
.
- aboutToDeleteRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToDelete
is triggerd and fires the corresponding DataBefore event
aboutToDelete
.
- aboutToDisconnect(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToDisconnect
is triggerd and fires the corresponding DataBefore event
aboutToDisconnect
.
- aboutToExecute(DataEvent)
- Invoked when the underlying com.ibm.db.StatementBefore event
aboutToExecute
is triggerd and fires the corresponding DataBefore event
aboutToExecute
.
- aboutToRollback(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToRollback
is triggerd and fires the corresponding DataBefore event
aboutToRollback
.
- aboutToSetColumnValue(PropertyChangeEvent)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToSetColumnValues
is triggerd.
- aboutToUpdateRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToUpdateRow
is triggerd and fires the corresponding DataBefore event
aboutToUpdateRow
.
- addDataAfterListener(DataAfterListener)
- Adds the DataAfterListener.
- addDataBeforeListener(DataBeforeListener)
- Adds the DataBeforeListener.
- addedNewRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
addedNewRow
is triggerd and fires the corresponding DataAfter event
addedNewRow
.
- addPropertyChangeListener(PropertyChangeListener)
- Adds the PropertyChangeListener.
- addTableModelListener(TableModelListener)
- Adds the TableModelListener.
- cacheRowsChanged(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
cacheRowsChanged
is triggerd and fires the corresponding DataAfter event
cacheRowsChanged
.
- close()
- Closes the result set.
- closed(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
closed
is triggerd and fires the corresponding DataAfter event
closed
.
- columnNames()
- Returns the names of the columns of the result set.
- columnValueSet(PropertyChangeEvent)
-
- commit()
- Commits changes to the database.
- committed(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
commmitted
is triggerd and fires the corresponding DataAfter event
committed
.
- connect()
- Attempts to establish a connection to the database using the connection properties
specified in the query property.
- connected(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
connected
is triggerd and fires the corresponding DataAfter event
connected
.
- deletedRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
deletedRow
is triggerd and fires the corresponding DataAfter event
deletedRow
.
- deleteRow()
- Deletes the current row from the result set and from the database.
- disconnect()
- If the connection represented by the connectionAlias is not currently being shared,
disconnects from the database and releases JDBC resources associated with the
connection.
- disconnected(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
disconnected
is triggerd and fires the corresponding DataAfter event
disconnected
.
- execute()
- Executes the SQL SELECT statement and positions to the first row in the result set.
- executed(DataEvent)
- Invoked when the underlying com.ibm.db.StatementAfter event
executed
is triggerd and fires the corresponding DataAfter event
executed
.
- firstRow()
- Applies any changes in the current row to the database, and then makes the first row
in the result set the current row.
- getColumnClass(int)
- Returns the java class that is used for the values of the column.
- getColumnClass(String)
- Returns the java class that is used for the values of the column.
- getColumnCount()
- Returns the number of columns in the result set.
- getColumnIndex(String)
- Returns the index of the column based on its name.
- getColumnName(int)
- Returns the name of the specified column.
- getColumnValue(int)
- Returns the value of the column at the specified index in the current row.
- getColumnValue(String)
- Returns the value of the column with the specified name in the current row.
- getColumnValueToString(int)
- Returns the value of the column at the specified index in the current row as a
String.
- getColumnValueToString(String)
- Returns the value of the column with the specified name in the current row as a
String.
- getCurrentRow()
- Returns the index of the current row in the result set.
- getCurrentRowInCache()
- Returns the index in the cache of the current row in the result set.
- getDatabaseConnection()
- Returns the underlying com.ibm.db.DatabaseConnection.
- getInstanceBeanInfo()
- Returns the BeanInfo that contains information about the instance properties of
this Select.
- getMaximumPacketsInCache()
- Returns the maximum number of packets the cache can contain.
- getMaximumRows()
- Returns the maximum size of the result set.
- getNumPacketsInCache()
- Returns the number of packets currently in the cache.
- getNumRows()
- Returns the number of rows in the result set.
- getNumRowsInCache()
- Returns the number of rows currently in the cache.
- getPacketSize()
- Returns the number of rows that are in one packet in the cache.
- getParameter(int)
- Returns the value of the parameter at the specified index.
- getParameter(String)
- Returns the value of the parameter with the specified name.
- getParameterToString(int)
- Returns the value of the parameter at the specified index as a String.
- getParameterToString(String)
- Returns the value of the parameter with the specified name as a String.
- getQuery()
- Returns a new Query object that contains references to the connection alias and
the SQL specification for this Select.
- getResult()
- Returns the underlying com.ibm.db.SelectResult.
- getRowCount()
- Returns the number of rows currently in the cache.
- getSelectStatement()
- Returns the underlying com.ibm.db.SelectStatement.
- getStatementMetaData()
- Returns the underlying com.ibm.db.StatementMetaData.
- getValueAt(int, int)
- Returns the value of the specified cell in the cache.
- isCellEditable(int, int)
- Returns true if
isReadOnly
returns false.
- isEnd()
- Returns true if the currentRow is the last row in the result set and no
more rows can be fetched.
- isExecuted()
- Returns true if
execute
has been invoked.
- isFillCacheOnExecute()
- Returns true if the entire cache will be filled when
execute
is invoked.
- isLockRows()
- Returns true if a database lock is automatically held on a row while
it is the current row.
- isMaxRowsReached()
- Returns true if the number of rows in the result set is equal to the
maximum size of the result set.
- isOpen()
- Returns true if the result set is open in the database and can be accessed,
otherwise returns false.
- isReadOnly()
- Returns true if updates are disallowed even when the database would permit them.
- lastRow()
- Applies any changes in the current row to the database, and then makes the last
row in the result set the current row.
- lockRow()
- Locks the current row in the database.
- newRow(boolean)
- Applies any changes in the current row to the database, and then inserts a new row
making it the current row.
- nextPacket()
- Fetches the next packet from the database into the result set.
- nextRow()
- Applies any changes in the current row to the database, and then makes the next row
in the result set the current row.
- previousRow()
- Applies any changes in the current row to the database, and then makes the previous row
in the result set the current row.
- propertyChange(PropertyChangeEvent)
- Method to handle events for the PropertyChangeListener interface.
- refresh()
- Refreshes the result set from the database by re-executing the SQL SELECT statement.
- removeDataAfterListener(DataAfterListener)
- Removes the DataAfterListener.
- removeDataBeforeListener(DataBeforeListener)
- Removes the DataBeforeListener.
- removePropertyChangeListener(PropertyChangeListener)
- Removes the PropertyChangeListener.
- removeTableModelListener(TableModelListener)
- Removes the TableModelListener.
- restoreRow()
- Restores a row's column values to those last known to be in the database.
- rollback()
- Rollback changes in the database.
- rolledBack(DataEvent)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
rolledBack
is triggerd and fires the corresponding DataAfter event
rolledBack
.
- setColumnValue(int, Object)
- Sets (in the result set) the value of the column at the specified index in the
current row.
- setColumnValue(String, Object)
- Sets (in the result set) the value of the column with the specified name in the
current row.
- setColumnValueFromString(int, String)
- Sets (in the result set) the value of the column at the specified index in the
current row.
- setColumnValueFromString(String, String)
- Sets (in the result set) the value of the column with the specified name in the
current row.
- setCurrentRow(int)
- Applies any changes in the current row to the database, and then makes the specified
row in the result set the current row.
- setCurrentRowInCache(int)
- Makes the specified row in the cache the currentRow in the result set.
- setDatabaseConnection(DatabaseConnection)
- Associates a DatabaseConnection with the Select.
- setFillCacheOnExecute(boolean)
- If true, the entire cache will be filled when
execute
is invoked.
- setLockRows(boolean)
- If true, a database lock is automatically held on a row while
it is the current row.
- setMaximumPacketsInCache(int)
- Sets the maximum number of packets the cache can contain.
- setMaximumRows(int)
- Sets the maximum size of the result set.
- setPacketSize(int)
- Sets the number of rows that are in one packet in the cache.
- setParameter(int, Object)
- Sets the parameter at the specified index to the specified value.
- setParameter(String, Object)
- Sets the parameter with the specified name to the specified value.
- setParameterFromString(int, String)
- Sets the parameter at the specified index to the specified value.
- setParameterFromString(String, String)
- Sets the parameter with the specified name to the specified value.
- setQuery(Query)
- Sets the connection alias and the SQL specification for this Select to the
values contained in the specified Query.
- setReadOnly(boolean)
- If true, updates are disallowed even when the database would permit them.
- setStatementMetaData(StatementMetaData)
- Associates a StatementMetaData with the Select.
- setValueAt(Object, int, int)
- Sets the specified cell in the cache to the specified value.
- unlockRow()
- Unlocks the current row.
- updatedRow(DataEvent)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
updatedRow
is triggerd and fires the corresponding DataAfter event
updatedRow
.
- updateRow()
- Updates the database with the values of the current row in the result set.
Constructors
Select
public Select()
- Constructs a new Select and initializes properties to the default values.
Methods
aboutToAddNewRow
public void aboutToAddNewRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToAddNewRow
is triggerd and fires the corresponding DataBefore event
aboutToAddNewRow
.
- Parameters:
- event - DataEvent
aboutToClose
public void aboutToClose(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToClose
is triggerd and fires the corresponding DataBefore event
aboutToClose
.
- Parameters:
- event - DataEvent
aboutToCommit
public void aboutToCommit(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToCommit
is triggerd and fires the corresponding DataBefore event
aboutToCommit
.
- Parameters:
- event - DataEvent
aboutToConnect
public void aboutToConnect(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToConnect
is triggerd and fires the corresponding DataBefore event
aboutToConnect
.
- Parameters:
- event - DataEvent
aboutToDeleteRow
public void aboutToDeleteRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToDelete
is triggerd and fires the corresponding DataBefore event
aboutToDelete
.
- Parameters:
- event - DataEvent
aboutToDisconnect
public void aboutToDisconnect(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToDisconnect
is triggerd and fires the corresponding DataBefore event
aboutToDisconnect
.
- Parameters:
- event - DataEvent
aboutToExecute
public void aboutToExecute(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementBefore event
aboutToExecute
is triggerd and fires the corresponding DataBefore event
aboutToExecute
.
- Parameters:
- event - DataEvent
aboutToRollback
public void aboutToRollback(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionBefore event
aboutToRollback
is triggerd and fires the corresponding DataBefore event
aboutToRollback
.
- Parameters:
- event - DataEvent
aboutToSetColumnValue
public void aboutToSetColumnValue(PropertyChangeEvent event)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToSetColumnValues
is triggerd. No action is taken.
- Parameters:
- event - DataEvent
aboutToUpdateRow
public void aboutToUpdateRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultBefore event
aboutToUpdateRow
is triggerd and fires the corresponding DataBefore event
aboutToUpdateRow
.
- Parameters:
- event - DataEvent
addDataAfterListener
public void addDataAfterListener(DataAfterListener newListener)
- Adds the DataAfterListener. DataAfter events occur after
actions have been completed.
- Parameters:
- newListener - DataAfterListener
- See Also:
- DataAfterListener, removeDataAfterListener
addDataBeforeListener
public void addDataBeforeListener(DataBeforeListener newListener)
- Adds the DataBeforeListener. DataBefore events occur after
actions have been completed.
- Parameters:
- newListener - DataBeforeListener
- See Also:
- DataBeforeListener, removeDataBeforeListener
addedNewRow
public void addedNewRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
addedNewRow
is triggerd and fires the corresponding DataAfter event
addedNewRow
.
- Parameters:
- event - DataEvent
addPropertyChangeListener
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
- Adds the PropertyChangeListener.
- Parameters:
- listener - PropertyChangeListener
- See Also:
- removePropertyChangeListener
addTableModelListener
public void addTableModelListener(TableModelListener newListener)
- Adds the TableModelListener.
- Parameters:
- newListener - tableModleListener
- See Also:
- removeTableModelListener
cacheRowsChanged
public void cacheRowsChanged(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
cacheRowsChanged
is triggerd and fires the corresponding DataAfter event
cacheRowsChanged
.
- Parameters:
- event - DataEvent
close
public void close() 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.
The events aboutToClose
and closed
are
triggered by this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- sqlException
- if a SQLException occurred
closed
public void closed(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
closed
is triggerd and fires the corresponding DataAfter event
closed
.
- Parameters:
- event - DataEvent
columnNames
public Enumeration columnNames() throws DataException
- Returns the names of the columns of the result set.
- Returns:
- enumeration containing column names
columnValueSet
public void columnValueSet(PropertyChangeEvent event)
commit
public void commit() throws DataException
- Commits changes to the database. All outstanding changes made to the database
using the connection associated with the connection alias are committed to the
database and any database locks currently held by the connection are released.
This method should only be used when auto commit has been disabled.
The events aboutToCommit
and committed
are triggered by
this method.
- Throws: DataException
- noActiveConnection
- if no active connection exists
- Throws: DataException
- sqlException
- if a SQL exception occurs
- See Also:
- rollback
committed
public void committed(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
commmitted
is triggerd and fires the corresponding DataAfter event
committed
.
- Parameters:
- event - DataEvent
connect
public void connect() throws DataException
- Attempts to establish a connection to the database using the connection properties
specified in the query property.
If a connection already exists for the specified connectionAlias, no new
connection is made and the existing connection is shared. If the value of
connectionAlias is null, a new connection is always established.
The events aboutToConnect
and connected
are triggered by
this method.
- Throws: DataException
- noGui
- if no GUI available and logon prompt requested
- Throws: DataException
- badUidPwd
- if incorrect Userid or password specified
- Throws: DataException
- sqlException
- if SQLException occurred
- See Also:
- disconnect
connected
public void connected(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
connected
is triggerd and fires the corresponding DataAfter event
connected
.
- Parameters:
- event - DataEvent
deletedRow
public void deletedRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
deletedRow
is triggerd and fires the corresponding DataAfter event
deletedRow
.
- Parameters:
- event - DataEvent
deleteRow
public void deleteRow() throws DataException
- Deletes the current row from the result set and from the database. If the last row
in the result set is deleted, the previous row becomes the current row. Otherwise,
the next row becomes the current row and the index returned by the
getCurrentRow
method does not change.
Before the database is updated, if the row is not already locked, the lockRow
method is implicitly invoked to insure that no other user has updated or deleted the
row in the database. A table must have been defined via addTable
in
order for this lock to be otbained. The database lock is released after the delete.
To insure that your delete affects the intended row in the database, make sure
that the SQL statement used to produce the result set includes columns that
uniquely identify a row. For a fuller
discussion of these points, see the lockRow
method.
The events aboutToDeleteRow
and deletedRow
are
triggered by this method.
The event cacheRowsChanged
may also be triggered.
- Throws: DataException
- notExecuted
- if the statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be deleted from the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- lockRow
disconnect
public void disconnect() throws DataException
- If the connection represented by the connectionAlias is not currently being shared,
disconnects from the database and releases JDBC resources associated with the
connection. If the connection is being shared, the use count is decremeted by 1.
The events aboutToDisconnect
and disconnected
are triggered by
this method.
- Throws: DataException
- noActiveConnection
- if no active Connection
- Throws: DataException
- sqlException
- if SQLException occurred
- See Also:
- connect
disconnected
public void disconnected(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
disconnected
is triggerd and fires the corresponding DataAfter event
disconnected
.
- Parameters:
- event - DataEvent
execute
public void execute() throws DataException
- Executes the SQL SELECT statement and positions to the first row in the result set.
If needed, a connection is made to the database prior to executing the
SQL statement.
The events aboutToExecute
and executed
are
triggered by this method.
The event cacheRowsChanged
is triggered
by this method.
- Throws: DataException
- noGui
- if no GUI available and logon prompt requested
- Throws: DataException
- badUidPwd
- if incorrect Userid or password specified
- Throws: DataException
- noSQL
- if SQL statement is null
- Throws: DataException
- notSelect
- if SQL statement is not a SELECT statement
- Throws: DataException
- sqlException
- if a SQLException occurred
executed
public void executed(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementAfter event
executed
is triggerd and fires the corresponding DataAfter event
executed
.
- Parameters:
- event - DataEvent
firstRow
public void firstRow() throws DataException
- Applies any changes in the current row to the database, and then makes the first row
in the result set the current row.
If the first row in the result set has been displaced from the cache, the first row
still in the cache becomes the current row and an exception is thrown to notify the
user that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true), the new current row is locked in the database.
The event cacheRowsChanged
may be triggered by this method.
- Throws: DataException
- notExecuted
- if the statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- beforeCacheStart
- if the requested row is before the start of the cache
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- setCurrentRow
getColumnClass
public Class getColumnClass(int columnIndex)
- Returns the java class that is used for the values of the column. If the columns have been
defined by
addColumn
, this method returns the java class used in the definition.
If the columns have not been defined by addColumn
, the java class is not available
until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the java class for the column
- Throws: IndexOutOfBoundsException
- if the column index is not defined
getColumnClass
public Class getColumnClass(String columnName)
- Returns the java class that is used for the values of the column. If the columns have been
defined by
addColumn
, this method returns the java class used in the definition.
If the columns have not been defined by addColumn
, the java class is not available
until after the SQL statement has been executed.
- Parameters:
- columnName - the name of the column
- Returns:
- the java class for the column
- Throws: IndexOutOfBoundsException
- if the column name is not defined
getColumnCount
public int getColumnCount()
- Returns the number of columns in the result set. If the columns have been
defined by
addColumn
, this method returns the number of columns that have
currently been defined. If the columns have not been defined by addColumn
, the number
of columns is not available until after the SQL statement has been executed.
- Returns:
- the number of columns
getColumnIndex
public int getColumnIndex(String columnName)
- Returns the index of the column based on its name. If the columns have been
defined by
addColumn
, this method returns an index representing the order
that the columns were defined. If the columns have not been defined by addColumn
,
the column index is not available until after the SQL statement has been executed. The first
defined column has an index of 0.
- Parameters:
- columnName - the name of the column
- Returns:
- the column index
getColumnName
public String getColumnName(int columnIndex)
- Returns the name of the specified column. If the columns have not been defined by
addColumn
, the name is not available until after the SQL statement has been executed.
- Parameters:
- columnNumber - the index of the column
- Returns:
- the column name
- Throws: IndexOutOfBoundsException
- if the column index is not defined
getColumnValue
public Object getColumnValue(int columnNumber) throws DataException
- Returns the value of the column at the specified index in the current row.
The index of the first column is 0.
If a DataException is raised attempting to get the column value because
the statement has not been executed or the resut set is empty,
the error is logged and a null value is returned.
- Parameters:
- columnNumber - index of the column
- Returns:
- value of the column
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column index is not defined
- See Also:
- setColumnValue
getColumnValue
public Object getColumnValue(String columnName) throws DataException
- Returns the value of the column with the specified name in the current row.
If a DataException is raised attempting to get the column value because
the statement has not been executed or the resut set is empty,
the error is logged and a null value is returned.
- Parameters:
- columnName - name of the column
- Returns:
- value of the column
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column name is not defined
- See Also:
- setColumnValue
getColumnValueToString
public String getColumnValueToString(int columnNumber) throws DataException
- Returns the value of the column at the specified index in the current row 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 0.
If a DataException is raised attempting to get the column value because
the statement has not been executed or the resut set is empty,
the error is logged and a null value is returned.
- Parameters:
- columnNumber - index of the column
- Returns:
- value of the column as a String.
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column index is not defined
- See Also:
- setColumnValueFromString
getColumnValueToString
public String getColumnValueToString(String columnName) throws DataException
- Returns the value of the column with the specified name in the current row 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.
If a DataException is raised attempting to get the column value because
the statement has not been executed or the resut set is empty,
the error is logged and a null value is returned.
- Parameters:
- columnName - name of the column
- Returns:
- value of the column as a String.
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column name is not defined
- See Also:
- setColumnValueFromString
getCurrentRow
public int getCurrentRow()
- Returns the index of the current row in the result set.
The index of the first row is 0.
Many methods on Select operate on the current row.
- Returns:
- index of the current row
- See Also:
- setCurrentRow
getCurrentRowInCache
public int getCurrentRowInCache()
- Returns the index in the cache of the current row in the result set.
The index of the first row in the cache is 0.
The value of currentRowInCache and currentRow will be the same unless
you are using the large result set support and a packet has been displaced from the
cache. For example, if a packet of 10 rows has been displaced from the cache and the
currentRow is 10, the currentRowInCache would be 0.
- Returns:
- index of the current row
getDatabaseConnection
public DatabaseConnection getDatabaseConnection()
- Returns the underlying com.ibm.db.DatabaseConnection.
- Returns:
- the associated DatabaseConnection
- Overrides:
- getDatabaseConnection in class Statement
- See Also:
- setDatabaseConnection
getInstanceBeanInfo
public BeanInfo getInstanceBeanInfo()
- Returns the BeanInfo that contains information about the instance properties of
this Select. This method is called by the VAJ IDE to display the columns from the
associated SQL statement on the connection dialog.
- Returns:
- beanInfo of instance properties
getMaximumPacketsInCache
public int getMaximumPacketsInCache()
- Returns the maximum number of packets the cache can contain.
- Returns:
- the maximum number of packets in the cache
- See Also:
- setMaximumPacketsInCache
getMaximumRows
public int getMaximumRows()
- Returns the maximum size of the result set. If there is no limit to the size
of the result set, the value will be 0.
- Returns:
- the maximum size of the result set.
- See Also:
- setMaximumRows
getNumPacketsInCache
public int getNumPacketsInCache()
- Returns the number of packets currently in the cache.
- Returns:
- the number of packets in the cache
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
getNumRowsInCache
public int getNumRowsInCache()
- Returns the number of rows currently in the cache.
- Returns:
- the number of rows in cache
getPacketSize
public int getPacketSize()
- Returns the number of rows that are in one packet in the cache.
- Returns:
- the size of the packet in the cache.
- See Also:
- setPacketSize
getParameter
public Object getParameter(int parameterNumber) throws DataException
- Returns the value of the parameter at the specified index.
The index of the first parameter is 1.
- Parameters:
- parameterNumber - index of the parameter
- Returns:
- the parameter value
- Throws: IndexOutOfBoundsException
- if the parameter index is not
defined
- See Also:
- setParameter
getParameter
public Object getParameter(String parameterName) throws DataException
- Returns the value of the parameter with the specified name.
- Parameters:
- parameterName - name of the parameter
- Returns:
- the parameter value
- Throws: IndexOutOfBoundsException
- if the parameter name is not
defined
- See Also:
- setParameter
getParameterToString
public String getParameterToString(int parameterNumber)
- Returns the value of the parameter at the specified index as a String. The value
of the parameter is converted to a String before the value is returned. If the
parameter value is null, a null is returned.
The index of the first parameter is 1.
- Parameters:
- parameterNumber - index of the parameter
- Returns:
- value of the parameter as a String
- Throws: IndexOutOfBoundsException
- if the parameter index is not
defined
- See Also:
- setParameterFromString
getParameterToString
public String getParameterToString(String parameterName)
- Returns the value of the parameter with the specified name as a String. The value
of the parameter is converted to a String before the value is returned. If the
parameter value is null, a null is returned.
- Parameters:
- parameterName - name of the parameter
- Returns:
- value of the parameter as a String
- Throws: IndexOutOfBoundsException
- if the parameter name is not
defined
- See Also:
- setParameterFromString
getQuery
public Query getQuery()
- Returns a new Query object that contains references to the connection alias and
the SQL specification for this Select.
- Returns:
- a new Query
- See Also:
- setQuery
getResult
public SelectResult getResult()
- Returns the underlying com.ibm.db.SelectResult.
- Returns:
- the associated SelectResult
getRowCount
public int getRowCount()
- Returns the number of rows currently in the cache.
- Returns:
- the number of rows in the cache
getSelectStatement
public SelectStatement getSelectStatement()
- Returns the underlying com.ibm.db.SelectStatement.
- Returns:
- the associated SelectStatement.
getStatementMetaData
public StatementMetaData getStatementMetaData()
- Returns the underlying com.ibm.db.StatementMetaData.
- Returns:
- the associated StatementMetaData
- See Also:
- setStatementMetaData
getValueAt
public Object getValueAt(int rowIndex,
int columnIndex)
- Returns the value of the specified cell in the cache. The index of both the
first row and the first column is 0.
- Returns:
- the value of the specified cell
isCellEditable
public boolean isCellEditable(int rowIndex,
int columnIndex)
- Returns true if
isReadOnly
returns false. If the
SQL statement returns a result set that cannot be updated, you should explicitly
set the ReadOnly property to true, so that the correct value is returned
for this method.
- Returns:
- true if
isReadOnly
returns false.
- See Also:
- setReadOnly
isEnd
public boolean isEnd()
- Returns true if the currentRow is the last row in the result set and no
more rows can be fetched. No more rows can be fetched if any of the following
conditions is true: all rows have been fetched from the database, the maxRows
limit has been reached, or the result set has been closed.
- Returns:
- true if the currentRow is the last row in the result set and no
more rows can be fetched
- See Also:
- isOpen, isMaxRowsReached
isExecuted
public boolean isExecuted()
- Returns true if
execute
has been invoked.
- Returns:
- true if
execute
has been invoked.
otherwise false.
isFillCacheOnExecute
public boolean isFillCacheOnExecute()
- Returns true if the entire cache will be filled when
execute
is invoked.
- Returns:
- true if the entire cache will be filled when
execute
is invoked, else false.
- See Also:
- setFillCacheOnExecute
isLockRows
public boolean isLockRows()
- Returns true if a database lock is automatically held on a row while
it is the current row. Returns false
if a database lock is only held on a row while it is being updated in the
database.
See lockRow
for a fuller
discussion of what it means for a row to be locked.
- Returns:
- The lockRows property value.
- See Also:
- setLockRows, lockRow
isMaxRowsReached
public boolean isMaxRowsReached()
- Returns true if the number of rows in the result set is equal to the
maximum size of the result set.
- Returns:
- true if the number of rows in the result set is equal to the
maximum size of the result set, otherwise false.
- See Also:
- setMaximumRows
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, rows cannot be fetched from the the database and
updates cannot be performed.
When
isOpen
returns false, it may be because the SQL statement
has not been executed, the close
method has been invoked, or this
Select has been serialized and then de-serialized.
- Returns:
- true if the result set is open in the database, otherwise false.
isReadOnly
public boolean isReadOnly()
- Returns true if updates are disallowed even when the database would permit them.
Returns false if updates are allowed as long as the database will permit them.
- Returns:
- true if updates are disallowed, otherwise false.
- See Also:
- setReadOnly
lastRow
public void lastRow() throws DataException
- Applies any changes in the current row to the database, and then makes the last
row in the result set the current row. If more rows can be fetched from the database
they are fetched before making the last row current. For a discussion of when more
rows can be fetched, see the
isEnd
method.
If the current row should be locked ( isLockRows
returns true), the new current row is locked in the database.
The event cacheRowsChanged
is triggered by this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- setCurrentRow
lockRow
public void lockRow() throws DataException
- Locks the current row in the database.
No updates can be made to this row by another user until the lock is released.
The lock is automatically released when you move to another row. You can release
the lock without moving to another row by invoking the
unlockRow
method.
The row is locked by opening a database cursor using a SELECT statement whose
WHERE clause should identify the one row whose column values are those last known to
this result set. If the row has been updated in the database by another user, it
will not be identified, and you cannot obtain the lock. An exception is thrown
in this case. A table must be defined via
addTable
in order for this SELECT statement to be generated.
To insure that no more than one row is identified, make sure the SELECT statement
associated with this result set includes columns that uniquely identify a row.
If more than one row is identified, more than one row is locked. Furthermore,
a subsequent updateRow
or deleteRow
will affect one of
the locked rows, but it is unpredictable whether this is the one you intended.
This situation cannot be detected, and no exception is thrown.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- rowNotFound
- if the current row cannot be locked in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotInDatabase
- if the current row cannot be locked in the database because it has not
yet been written to the database
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- unlockRow
newRow
public void newRow(boolean beforeCurrent) throws DataException
- Applies any changes in the current row to the database, and then inserts a new row
making it the current row. Use the
setColumnValue
method to set values for its columns. The new row is not inserted into the database
until you move to another row or invoke the updateRow
method.
The events aboutToAddNewRow
, addedNewRow
, and
cacheRowsChanged
are triggered by this method.
- Parameters:
- beforeCurrent - true, insert the new row before the current row;
false insert the new row after the current row.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- maxSize
- if the maximum number of rows in the result set has been reached
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
nextPacket
public void nextPacket() throws DataException
- Fetches the next packet from the database into the result set. If this causes
the current row to be displaced from the cache any changes in the current row
are first applied to the database, and then the first row in the cache becomes the
current row.
The event cacheRowsChanged
is triggered by this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- sqlException
- if a SQLException occurred
nextRow
public void nextRow() throws DataException
- Applies any changes in the current row to the database, and then makes the next row
in the result set the current row.
If the next row has not already been fetched from the database, it is fetched, along
with any other rows in the next packet. If no more rows can be fetched, the last row
remains the current row, and no exception is thrown.
Thus, if you are at the end of the result set, repeatedly invoking this method has
no effect. For a discussion of when no more rows can be fetched, see the
isEnd
method.
If the current row should be locked ( isLockRows
returns true),
the new current row is locked in the database.
The event cacheRowsChanged
is triggered by this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- setCurrentRow
previousRow
public void previousRow() throws DataException
- Applies any changes in the current row to the database, and then makes the previous row
in the result set the current row.
If you are already on the first row, it remains the current row, and no exception is thrown.
Thus, if you are at the beginning of the result set, repeatedly invoking this method has
no effect.
If the previous row has been displaced from the cache, the first row in the cache
remains the current row and an exception is thrown to notify the
user that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true), the new current row is locked in the database.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property of the associated SelectStatement is true and
the new current row cannot be locked
- Throws: DataException
- beforeCacheStart
- if the requested row is before the start of the cache
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- setCurrentRow
propertyChange
public void propertyChange(PropertyChangeEvent arg1)
- Method to handle events for the PropertyChangeListener interface.
- Parameters:
- arg1 - java.beans.PropertyChangeEvent
refresh
public void refresh() throws DataException
- Refreshes the result set from the database by re-executing the SQL SELECT statement.
The statement must currently be open.
The event cacheRowsChanged
is triggered by this method.
- Throws: DataException
- noActiveConnection
- if no active connection exists
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- execute
removeDataAfterListener
public void removeDataAfterListener(DataAfterListener newListener)
- Removes the DataAfterListener. DataAfter events occur after
actions have been completed.
- Parameters:
- newListener - DataAfterListener
- See Also:
- DataAfterListener, addDataAfterListener
removeDataBeforeListener
public void removeDataBeforeListener(DataBeforeListener newListener)
- Removes the DataBeforeListener. DataBefore events occur after
actions have been completed.
- Parameters:
- newListener - DataBeforeListener
- See Also:
- DataBeforeListener, addDataBeforeListener
removePropertyChangeListener
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
- Removes the PropertyChangeListener.
- Parameters:
- listener - PropertyChangeListener
- See Also:
- addPropertyChangeListener
removeTableModelListener
public void removeTableModelListener(TableModelListener newListener)
- Removes the TableModelListener.
- Parameters:
- newListener - tableModleListener
- See Also:
- addTableModelListener
restoreRow
public void restoreRow() throws DataException
- Restores a row's column values to those last known to be in the database.
Use this method when an attempt to lock a row, write a row in the database,
or delete a row from the database failed. This can occur implicitly when
you try to move to another row. When one of these failures has occurred,
you cannot move to another row until you either correct the problem or
use this method.
If the current row was added via the newRow
method, its
column values are reset to nulls. Otherwise, its column values are reset
to the the values originally fetched from the database or the values to
which it was last successfully updated.
If you believe the failure that occurred is correctible by changing one
or more of column values, as for example if the failure was due to
a duplicate key value in the database, you can just change the values
and try the operation again instead of using this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- readOnly
- if the result set is read only
rollback
public void rollback() throws DataException
- Rollback changes in the database. All changes made since the previous
commit/rollback are rolled back and any database locks currently held
by the connection are released. This method should only be used when auto
commit has been disabled.
The events aboutToRollback
and rolledBack
are triggered by
this method.
- Throws: DataException
- noActiveConnection
- if no active connection exists
- Throws: DataException
- sqlException
- if a SQL exception occurs
- See Also:
- commit
rolledBack
public void rolledBack(DataEvent event)
- Invoked when the underlying com.ibm.db.DatabaseConnectionAfter event
rolledBack
is triggerd and fires the corresponding DataAfter event
rolledBack
.
- Parameters:
- event - DataEvent
setColumnValue
public void setColumnValue(int columnNumber,
Object aValue) throws DataException
- Sets (in the result set) the value of the column at the specified index in the
current row. The index of the first column is 0.
The column value is not updated in the database until you move to
another row or invoke updateRow
.
- Parameters:
- columnNumber - index of the column
- aValue - value for the column
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- noResults
- if the result set is empty
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column index is not defined
- Throws: DataException
- wrongObjectType
- if the value does match the object type of the column
- See Also:
- getColumnValue
setColumnValue
public void setColumnValue(String columnName,
Object aValue) throws DataException
- Sets (in the result set) the value of the column with the specified name in the
current row.
The column value is not updated in the database until you move to
another row or invoke updateRow
.
- Parameters:
- columnName - name of the column
- aValue - value for the column
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- noResults
- if the result set is empty
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column name is not defined
- Throws: DataException
- wrongObjectType
- if the value does match the object type of the column
- See Also:
- getColumnValue
setColumnValueFromString
public void setColumnValueFromString(int columnNumber,
String stringValue) throws DataException
- Sets (in the result set) the value of the column at the specified index in the
current row. The index of the first column is 0.
The stringValue parameter is converted to the datatype associated
with the column before the value is set.
The column value is not updated in the database until you move to another row or
invoke updateRow
.
- Parameters:
- columnNumber - index of the column
- stringValue - value for the column
- Throws: DataException
- notExecuted
- if associated statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- noResults
- if the result set is empty
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column index is not defined
- Throws: DataException
- cannotConvert
- if cannot convert to object type of column
of the column
- See Also:
- getColumnValueToString
setColumnValueFromString
public void setColumnValueFromString(String columnName,
String stringValue) throws DataException
- Sets (in the result set) the value of the column with the specified name in the
current row.
The stringValue parameter is converted to the datatype associated
with the column before the value is set.
The column value is not updated in the database until you move to another row or
invoke updateRow
.
- Parameters:
- columnName - name of the column
- stringValue - value for the column
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- noResults
- if the result set is empty
- Throws: IndexOutOfBoundsException
- noSuchColumn
- if the column name is not defined
- Throws: DataException
- cannotConvert
- if cannot convert to object type of column
- See Also:
- getColumnValueToString
setCurrentRow
public void setCurrentRow(int currentRow) throws DataException
- Applies any changes in the current row to the database, and then makes the specified
row in the result set the current row.
If the specified row has not yet been fetched, packets are fetched until the
specified row is in the cache or no more rows can be fetched.
If no more rows can be fetched, and the specified row was not reached, the last row
becomes the current row and an exception is thrown to notify the
user that the request could not be satisfied. For a discussion of when no more
rows can be fetched, see the isEnd
method.
If the specified row has been displaced from the cache, the first row in the cache
becomes the current row and an exception is thrown to notify the
user that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true), the new current row is locked in the database.
The event cacheRowsChanged
may be triggered by this method.
- Parameters:
- rowNumber - index in the result set of the row
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property is true and
the new current row cannot be locked
- Throws: DataException
- beforeCacheStart
- if the requested row is before the start of the cache
- Throws: DataException
- indexTooLarge
- if the requested row is after the end of the result set
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- getCurrentRow
setCurrentRowInCache
public void setCurrentRowInCache(int row) throws DataException
- Makes the specified row in the cache the currentRow in the result set. The value
currentRowInCache and currentRow will be the same unless you are using the large
result set support and a packet has been displaced from the cache.
- Parameters:
- row - the index of the row in the cache
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- rowNotFound
- if the lockRows property true and
the new current row cannot be locked
- Throws: DataException
- beforeCacheStart
- if the requested row is before the start of the cache
- Throws: DataException
- indexTooLarge
- if the requested row is after the end of the result set
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- setCurrentRow
setDatabaseConnection
public void setDatabaseConnection(DatabaseConnection connection)
- Associates a DatabaseConnection with the Select.
- Parameters:
- connection - the associated DatabaseConnection
- Overrides:
- setDatabaseConnection in class Statement
- See Also:
- getDatabaseConnection
setFillCacheOnExecute
public void setFillCacheOnExecute(boolean fillCache)
- If true, the entire cache will be filled when
execute
is invoked. Otherwise, rows will be fetched into the cache as needed to satisfy
a request to set the current row position.
The default value is true.
- Parameters:
- fillCacheOnExecute - true, fill entire cache on
execute
;
false fill cache only as needed
- See Also:
- getFillCacheOnExecute
setLockRows
public void setLockRows(boolean lockRows)
- If true, a database lock is automatically held on a row while
it is the current row. If false,
a database lock is only held on a row while it is being updated in the
database.
The default value is false.
See lockRow
for a fuller
discussion of what it means for a row to be locked.
- Parameters:
- lockRows - true, hold database lock while a row is the current row;
false hold database lock only while a row is updated.
- See Also:
- getLockRows, lockRow
setMaximumPacketsInCache
public void setMaximumPacketsInCache(int maximumPacketsInCache)
- Sets the maximum number of packets the cache can contain. Set the value to 0 if there
is no limit on the number of packets in the cache.
The default value is 0.
- Parameters:
- maximumPacketsInCache - the maximum number of packets in cache
- See Also:
- getMaximumPacketsInCache
setMaximumRows
public void setMaximumRows(int maximumRows)
- Sets the maximum size of the result set. Set the value to 0 if there is
no limit on the number of rows that can be contained in the result set.
The default value is 0.
- Parameters:
- maximumRows - the maximum number of rows in the result set
- See Also:
- getMaximumRows
setPacketSize
public void setPacketSize(int packetSize)
- Sets the number of rows that are in one packet in the cache. Set the value to 0 if there
is no limit on the number of rows in a packet.
The default value is 0.
- Parameters:
- packetSize - the size of the packet in the cache
- See Also:
- getPacketSize
setParameter
public void setParameter(int parameterNumber,
Object aValue) throws DataException
- Sets the parameter at the specified index to the specified value.
The index of the first parameter is 1.
- Parameters:
- parameterNumber - index of the parameter
- aValue - parameter value
- Throws: IndexOutOfBoundsException
- if the parameter index is not
defined
- Throws: DataException
- if the value does match the object type
of the parameter
- See Also:
- getParameter
setParameter
public void setParameter(String parameterName,
Object aValue) throws DataException
- Sets the parameter with the specified name to the specified value.
- Parameters:
- parameterName - name of the parameter
- aValue - parameter value
- Throws: IndexOutOfBoundsException
- if the parameter name is not
defined
- Throws: DataException
- if the value does match the object type
of the parameter
- See Also:
- getParameter
setParameterFromString
public void setParameterFromString(int parameterNumber,
String stringValue) throws DataException
- Sets the parameter at the specified index to the specified value. The stringValue
is converted to the datatype associated with the parameter before the
parameter is updated. The index of the first parameter is 1.
- Parameters:
- parameterNumber - index of the parameter
- stringValue - parameter value as a String
- Throws: IndexOutOfBoundsException
- if the parameter index is not
defined
- Throws: DataException
- if the value does match the object type
of the parameter
- See Also:
- getParameterToString
setParameterFromString
public void setParameterFromString(String parameterName,
String stringValue) throws DataException
- Sets the parameter with the specified name to the specified value. The stringValue
is converted to the datatype associated with the parameter before the
parameter is updated.
- Parameters:
- parameterName - name of the parameter
- stringValue - parameter value as a String
- Throws: IndexOutOfBoundsException
- if the parameter name is not
defined
- Throws: DataException
- if the value does match the object type
of the parameter
- See Also:
- getParameterToString
setQuery
public void setQuery(Query query)
- Sets the connection alias and the SQL specification for this Select to the
values contained in the specified Query. The Query itself is not saved.
- Parameters:
- query - the Query
- See Also:
- getQuery
setReadOnly
public void setReadOnly(boolean readOnly)
- If true, updates are disallowed even when the database would permit them.
If false, updates are allowed as long as the database will permit them.
The default value is false.
- Parameters:
- aValue - true if updates are disallowed;
false if updates are allowed.
- See Also:
- isReadOnly
setStatementMetaData
public void setStatementMetaData(StatementMetaData metaData)
- Associates a StatementMetaData with the Select.
- Parameters:
- metaData - the associated StatementMetaData
- See Also:
- getStatementMetaData
setValueAt
public void setValueAt(Object aValue,
int rowIndex,
int columnIndex)
- Sets the specified cell in the cache to the specified value. The index of both the
first row and the first column is 0. The cell value is not updated in the
database until you move to another row or invoke
updateRow
.
The row in the result set that corresponds to the specified row in the cache is
made the current row.
- Returns:
- the value of the specified cell
unlockRow
public void unlockRow() throws DataException
- Unlocks the current row. The database lock on the current row is released.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- sqlException
- if a SQLException occurred
- See Also:
- lockRow
updatedRow
public void updatedRow(DataEvent event)
- Invoked when the underlying com.ibm.db.StatementResultAfter event
updatedRow
is triggerd and fires the corresponding DataAfter event
updatedRow
.
- Parameters:
- event - DataEvent
updateRow
public void updateRow() throws DataException
- Updates the database with the values of the current row in the result set. If the
current row is a new row, it is INSERTed into the database. If it is an existing
row, it is UPDATEd in the database.
For an existing row, before the database is updated, if the row is not already locked,
the lockRow
method is implicitly invoked to insure that no other user
has updated or deleted the row in the database. A table must have been defined
via addTable
in order for this lock to
be obtained. The database lock is released after
the update unless the lockRows
property
is true. To insure that your update affects the intended row in the database,
make sure the SQL statement includes columns that uniquely identify
a row. See the lockRow
method for a fuller discussion of these points.
The events aboutToUpdateRow
and updatedRow
are
triggered by this method.
- Throws: DataException
- notExecuted
- if statement has not been executed
- Throws: DataException
- noResults
- if the result set is empty
- Throws: DataException
- readOnly
- if the result set is read only
- Throws: DataException
- notOpen
- if the result set is not open
- Throws: DataException
- rowChanged
- if the current row cannot be updated in the database because it has been
modified by another user since it was fetched
- Throws: DataException
- sqlException
- if a SQLException occurred
