|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.Statement | +--com.ibm.db.SelectStatement
SelectStatement represents an SQL Select statement.
Statement
, Serialized FormConstructor Summary | |
SelectStatement()
Constructs a new SelectStatement. |
|
SelectStatement(boolean forVAJava)
Constructs a new SelectStatement. |
Method Summary | |
void |
aboutToCommit(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionBefore event aboutToCommmit fires. |
void |
aboutToConnect(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionBefore event aboutToConnect fires. |
void |
aboutToDisconnect(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionBefore event aboutToDisconnect fires. |
void |
aboutToRollback(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionBefore event aboutToRollback fires. |
boolean |
areDistinctTypesEnabled()
Returns true if use of user-defined distinct types is enabled for this statement. |
void |
cancelExecution()
Cancels execution of the SQL statement which is associated with this SelectStatement. |
void |
close()
Applies any changes in the current row of the associated Select Result to the database, and then closes the result set and the statement. |
void |
committed(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionAfter event commmitted fires. |
void |
connected(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionAfter event connected fires. |
void |
disconnected(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionAfter event disconnected fires and closes the statement. |
void |
execute()
Executes the SQL SELECT statement and positions to the first row in the result set. |
int |
getMaximumPacketsInCache()
Returns the maximum number of packets the cache can contain at one time. |
int |
getMaximumRows()
Returns the maximum size of the result set. |
int |
getPacketSize()
Returns the number of rows that are in one packet. |
SelectResult |
getResult()
Returns the SelectResult that is associated with this SelectStatement. |
boolean |
isFillCacheOnExecute()
Returns true if as many rows as allowed are fetched into the cache when execute is invoked. |
boolean |
isForceSearchedUpdate()
Returns true if searched update/delete will always be done when updateRow()/deleteRow() is invoked. |
boolean |
isLargeResultSetScrollingEnabled()
Returns true if full scrollability of large result sets is enabled for this statement. |
boolean |
isLockRows()
Returns true if a database lock is automatically held on a row while it is the current row in the associated Select Result. |
boolean |
isOpen()
Returns true if the statement is open in the database and can be accessed, otherwise returns false. |
void |
refresh()
Refreshes the result set from the database by re-executing the SQL SELECT statement. |
void |
rolledBack(DataEvent event)
Invoked when the com.ibm.db.DatabaseConnectionAfter event rolledBack fires. |
void |
setConnection(DatabaseConnection connection)
Associates a DatabaseConnection with the Statement. |
void |
setDistinctTypesEnabled(boolean aValue)
If true, enables the use of user-defined distinct types for this statement. |
void |
setFillCacheOnExecute(boolean fillCacheOnExecute)
If true, fetches as many rows as allowed into the cache when execute is invoked. |
void |
setForceSearchedUpdate(boolean forceSearchedUpdate)
If true, a searched update will be done when updateRow()
is invoked and a searched delete will be done when deleteRow()
is invoked. |
void |
setLargeResultSetScrollingEnabled(boolean enabled)
If true, enables full scrollability of large result sets for this statement. |
void |
setLockRows(boolean lockRows)
If true, a database lock is automatically held on a row while it is the current row in the associated Select Result. |
void |
setMaximumPacketsInCache(int maximumPacketsInCache)
Sets the maximum number of packets the cache can contain at one time. |
void |
setMaximumRows(int maximumRows)
Sets the maximum size of the result set. |
void |
setMetaData(StatementMetaData metaData)
Associates a StatementMetaData with the Statement. |
void |
setPacketSize(int packetSize)
Sets the number of rows that are in one packet. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public SelectStatement()
public SelectStatement(boolean forVAJava)
forVAJava
is true,
messages that refer to a row number, a column number, or the current row will
be reported in VisualAge for Java Select bean terms (zero-based),
instead of one-based.
This constructor only be used by classes in com.ibm.ivj.db.uibeans package.
forVAJava
- if true report row, column and currentRow in VisualAge
terms.Method Detail |
public void aboutToCommit(DataEvent event)
aboutToCommmit
fires. Updates the current row.event
- a DataEventpublic void aboutToConnect(DataEvent event)
aboutToConnect
fires. Takes no action.event
- a DataEventpublic void aboutToDisconnect(DataEvent event)
aboutToDisconnect
fires. Takes no action.event
- a DataEventpublic void aboutToRollback(DataEvent event)
aboutToRollback
fires. Takes no action.event
- a DataEventpublic boolean areDistinctTypesEnabled()
setDistinctTypesEnabled
method for a fuller
discussion of what it means for use of user-defined distinct types to be enabled.setDistinctTypesEnabled(boolean)
public void cancelExecution() throws DataException
public void close() throws DataException
Even if you do not explicitly call close()
,
JDBC resources are automatically freed when your SelectStatement is garbage collected,
However, changes to the current row are not automatically applied in that case.
The events aboutToClose
and closed
are
triggered by this method.
public void committed(DataEvent event)
commmitted
fires. Takes no action.event
- a DataEventpublic void connected(DataEvent event)
connected
fires. Takes no actionevent
- a DataEventpublic void disconnected(DataEvent event)
disconnected
fires and closes the statement.event
- a DataEventpublic void execute() throws DataException
The events aboutToExecute
and executed
are
triggered by this method.
The event cacheRowsChanged
of the associated SelectResult is triggered
by this method.
The event propertyChange
is triggered by this method for the
bound properties currentRow and currentRowInCache.
DatabaseConnection
,
StatementMetaData
,
SelectResult
public int getMaximumPacketsInCache()
The number of rows the cache can contain at one time is the number of packets it can contain times the number of rows in a packet.
setMaximumPacketsInCache(int)
,
getPacketSize()
public int getMaximumRows()
This limit governs how many rows can be fetched in total over time. not how many rows the cache can contain at one time.
setMaximumRows(int)
public int getPacketSize()
execute
or nextRow
,
if any rows must be fetched, a whole packet of rows is fetched.
A packet is also the unit in which rows are displaced from the cache when it is full
and more rows must be fetched.
If the value for the packet size is less than 1, the default packet size of 1 is used.
setPacketSize(int)
,
getMaximumPacketsInCache()
public SelectResult getResult()
public boolean isFillCacheOnExecute()
execute
is invoked.
Returns false if rows are fetched into the cache only as needed to satisfy
a request to set the current row position.
The number of rows you are allowed to fetch into the cache is the smallest of: the total number of rows, the number of rows in a packet times the maximum number of packets allowed in the cache, and the maximum number of rows you are allowed to fetch over time.
If rows are fetched only as needed, one packet of rows is fetched on execute
.
execute
; else false.setFillCacheOnExecute(boolean)
,
getPacketSize()
,
getMaximumPacketsInCache()
,
getMaximumRows()
,
CallableStatement.isFillResultCacheOnExecute()
public boolean isForceSearchedUpdate()
updateRow()/deleteRow()
is invoked.setForceSearchedUpdate(boolean)
public boolean isLargeResultSetScrollingEnabled()
setLargeResultSetScrollingEnabled
method for a fuller
discussion of how this setting is used and why it is needed.setLargeResultSetScrollingEnabled(boolean)
public boolean isLockRows()
See the lockRow
method of SelectResult for a fuller
discussion of what it means for a row to be locked.
setLockRows(boolean)
,
SelectResult.lockRow()
public boolean isOpen()
close
method has been invoked, you have
disconnected from the database, or the SelectStatement has been serialized and
then de-serialized.public void refresh() throws DataException
execute
method.
The event cacheRowsChanged
of the associated SelectResult is triggered
by this method.
The events aboutToExecute
and executed
are
triggered by this method.
The event propertyChange
is triggered by this method for the
bound properties currentRow and currentRowInCache.
execute()
public void rolledBack(DataEvent event)
rolledBack
fires. Takes no action.event
- a DataEventpublic void setConnection(DatabaseConnection connection)
connection
- the associated DatabaseConnectionStatement.getConnection()
public void setDistinctTypesEnabled(boolean aValue)
If you never execute this method for a Statement, the value defaults to false.
When use of user-defined distinct types is not enabled for a statement, and the result set contains columns with user-defined distinct types, you cannot use a result set produced from the statement to update, delete, or lock a row. You can, however, retrieve data of user-defined types, and you can use the result set to insert rows in the database.
When use of user-defined distinct types is enabled for a statement, you can retrieve data of user defined types, as well as use the result set to insert, update, delete, or lock rows.
Implementation of this feature makes use of the CAST specification in SQL. The database you are using must support casting if you turn this enablement on. It does no harm to turn enablement on even if your statement uses no user-defined distinct types, but the SQL the bean generates to update, delete, or lock a row will be more complex, making use of the CAST specification for all columns.
aValue
- true if use of user-defined distinct types should be enabled;
false if it should not be enabled.
areDistinctTypesEnabled()
public void setFillCacheOnExecute(boolean fillCacheOnExecute)
execute
is invoked.
Otherwise, rows are fetched into the cache as needed to satisfy
a request to set the current row position.
The number of rows you are allowed to fetch into the cache is the smallest of: the total number of rows, the number of rows in a packet times the maximum number of packets allowed in the cache, and the maximum number of rows you are allowed to fetch over time.
If rows are fetched only as needed, one packet of rows is fetched on execute
.
If you never execute this method for a SelectStatement, the value defaults to true.
fillCacheOnExecute
- true, fetch as many rows as allowed on execute
;
false fetch rows only as neededisFillCacheOnExecute()
,
setPacketSize(int)
,
setMaximumPacketsInCache(int)
,
setMaximumRows(int)
public void setForceSearchedUpdate(boolean forceSearchedUpdate)
updateRow()
is invoked and a searched delete will be done when deleteRow()
is invoked.
By default, searched updates and deletes are only done for Oracle, Microsoft SQL Server, Sybase SQL Server, and databases which do not support positioned updates and deletes (as reported in the JDBC DatabaseMetaData).
For other databases, positioned updates and deletes are attempted. If these are
being attempted but failing, you can use this method to force searched updates
and deletes, which should be universally supported. See the updateRow
and deleteRow
methods of SelectResult for the implications of doing
positioned versus searched updates and deletes.
If you do not execute this method for a SelectStatement, the value defaults to false.
forceSearchedUpdate
- true, always use a searched update/delete;
false use a positioned update/delete if database supports it
isForceSearchedUpdate()
,
SelectResult.updateRow()
,
SelectResult.deleteRow()
public void setLargeResultSetScrollingEnabled(boolean enabled)
If you never execute this method for a Statement, the value defaults to false.
If you are limiting the number of rows in the cache to accommodate large result sets, you will need a scrollable result set in the underlying database in order to have full scrollability in the SelectResult. This requires a database driver at the JDBC 2.0 level.
A JDK bug has precluded doing appropriate reflection on the driver classes to determine whether the driver is at the JDBC 2.0 level. Because, the bug is severe, either crashing the java.exe process or hanging the thread, use of scrollable result sets in the database will not be attempted unless this method has been used to enable them. As long as the database driver actually is at the JDBC 2.0 level, the bug will not occur.
enabled
- true if full scrollability of large result sets should be enabled;
false if it should not be enabled.
isLargeResultSetScrollingEnabled()
public void setLockRows(boolean lockRows)
If you never execute this method for a SelectStatement, the value defaults to false.
See the lockRow
method of SelectResult for a fuller
discussion of what it means for a row to be locked.
lockRows
- true, hold database lock while a row is the current row;
false hold database lock only while a row is being updated.isLockRows()
,
SelectResult.lockRow()
public void setMaximumPacketsInCache(int maximumPacketsInCache)
The number of rows the cache can contain at one time is the number of packets it can contain times the number of rows in a packet.
If you never execute this method for a SelectStatement, the value defaults to 0.
maximumPacketsInCache
- the maximum number of packets in cachegetMaximumPacketsInCache()
,
setPacketSize(int)
public void setMaximumRows(int maximumRows)
This limit governs how many rows can be fetched in total over time. not how many rows the cache can contain at one time.
If you never execute this method for a SelectStatement, the value defaults to 0.
maximumRows
- the maximum number of rows in the result setgetMaximumRows()
public void setMetaData(StatementMetaData metaData)
metaData
- the associated StatementMetaDataStatement.getMetaData()
public void setPacketSize(int packetSize)
execute
or nextRow
,
if any rows must be fetched, a whole packet of rows is fetched.
A packet is also the unit in which rows are displaced from the cache when it is full
and more rows must be fetched.
If you never execute this method for a SelectStatement, the value defaults to 1. Setting the value to less than 1 has the same effect as allowing it to default to 1.
packetSize
- the number of rows in a packetgetPacketSize()
,
setMaximumPacketsInCache(int)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |