|
|||||||||
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 FormField Summary | |
private static java.lang.String |
copyright
|
protected boolean |
executing
|
protected boolean |
fieldFillCacheOnExecute
|
protected boolean |
fieldForceSearchedUpdate
|
protected boolean |
fieldLockRows
|
protected int |
fieldMaximumPacketsInCache
|
protected int |
fieldMaximumRows
|
protected int |
fieldPacketSize
|
private SelectResult |
fieldResult
|
protected boolean |
firstFirstRow
|
protected boolean |
forVAJavaSelect
|
protected boolean |
largeResultSetScrollingEnabled
|
(package private) static long |
serialVersionUID
|
Fields inherited from class com.ibm.db.Statement |
aStatementAfterListener,
aStatementBeforeListener,
copyright,
executingSQL,
fieldConnection,
fieldDistinctTypesEnabled,
fieldExecuted,
fieldMetaData,
fieldReadOnly,
fieldTimeout,
fieldValidateLOBs,
parameters,
propertyChange,
rt,
serialVersionUID |
Constructor 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. |
protected void |
checkConnection()
This method is called to do cleanup of the statement and any result sets when it is found that there is no active connection. |
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. |
protected void |
closeInternal(boolean finalizing)
Closes 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. |
protected void |
createResultTable()
This method was created in VisualAge. |
protected void |
disconnect()
This method was created in VisualAge. |
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. |
protected void |
finalize()
Code to perform when this object is garbage collected. |
protected void |
fireAboutToClose(DataEvent event)
Method to support listener events. |
protected void |
fireClosed(DataEvent event)
Method to support listener events. |
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. |
protected void |
initialize()
Initialize the class. |
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. |
protected boolean |
isForVAJavaSelect()
Returns true if the statement is for a VA for Java Select bean. |
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. |
private void |
readObject(java.io.ObjectInputStream in)
This method was reads in the serialized object and restores the following static/transient fields: propertyChange - contains a reference to a PropertyChangeSupport instance. |
void |
refresh()
Refreshes the result set from the database by re-executing the SQL SELECT statement. |
protected void |
refreshResultTable()
This method was created in VisualAge. |
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. |
protected void |
validateSQL()
|
Methods inherited from class java.lang.Object |
|
Field Detail |
protected boolean fieldLockRows
protected int fieldMaximumPacketsInCache
private SelectResult fieldResult
protected int fieldMaximumRows
protected int fieldPacketSize
protected boolean fieldFillCacheOnExecute
protected boolean fieldForceSearchedUpdate
protected boolean forVAJavaSelect
protected boolean largeResultSetScrollingEnabled
protected transient boolean executing
protected transient boolean firstFirstRow
static final long serialVersionUID
private static final java.lang.String copyright
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
protected void checkConnection() 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.
protected void closeInternal(boolean finalizing) throws DataException
finalizing
- if true, do not update the current row before closing
and do not throw any exceptions.public void committed(DataEvent event)
commmitted
fires. Takes no action.event
- a DataEventpublic void connected(DataEvent event)
connected
fires. Takes no actionevent
- a DataEventprotected void createResultTable() throws DataException
protected void disconnect()
public 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
protected void finalize() throws java.lang.Throwable
protected void fireAboutToClose(DataEvent event)
event
- DataEventprotected void fireClosed(DataEvent event)
event
- DataEventpublic 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()
protected void initialize()
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)
protected boolean isForVAJavaSelect()
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.private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- ObjectInputStreampublic 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()
protected void refreshResultTable() throws DataException
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)
protected void validateSQL() throws DataException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |