|
|||||||||
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 | +--com.ibm.db.CallableStatement
CallableStatement represents an SQL statement that can be used to execute a stored procedure.
Statement
, Serialized FormField Summary | |
private static java.lang.String |
copyright
|
protected boolean |
describeAtRuntime
|
protected int |
fieldCurrentResult
|
protected int |
fieldCurrentResultInCache
|
protected boolean |
fieldFillResultCacheOnExecute
|
protected int |
fieldMaximumResultsInCache
|
protected java.util.Vector |
fieldMetaDataVector
|
protected int |
fieldNumResults
|
protected int |
fieldNumResultsInCache
|
protected java.util.Vector |
fieldResult
|
protected boolean |
moreResults
|
protected boolean |
nextOrPrev
|
protected boolean[] |
outputParameterFetched
|
(package private) static long |
serialVersionUID
|
Fields inherited from class com.ibm.db.SelectStatement |
copyright,
executing,
fieldFillCacheOnExecute,
fieldForceSearchedUpdate,
fieldLockRows,
fieldMaximumPacketsInCache,
fieldMaximumRows,
fieldPacketSize,
fieldResult,
firstFirstRow,
forVAJavaSelect,
largeResultSetScrollingEnabled,
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 | |
CallableStatement()
Constructs a new CallableStatement. |
|
CallableStatement(boolean forVAJava)
Constructs a new CallableStatement. |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener to the PropertyChange event set. |
void |
cancelExecution()
Cancels execution of the SQL statement which is associated with this CallableStatement. |
void |
close()
Applies any changes in the current row of the current Select Result to the database, and then closes the result set and the statement. |
protected void |
createResultTable()
This method was created in VisualAge. |
protected void |
disconnect()
This method was created in VisualAge. |
void |
execute()
Executes the SQL CALL statement and, if any result sets were produced, positions to the first row in the first result set. |
protected void |
fetchFirstResult()
This method was created in VisualAge. |
protected void |
fetchNextResult()
This method was created in VisualAge. |
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
The firePropertyChange method was generated to support the propertyChange field. |
void |
firstResult()
Applies any changes in the current row of the current result set to the database, and then positions to the first result set (if any result sets were returned). |
SelectResult |
getCacheResultAt(int resultNumber)
Returns the SelectResult at the specified index. |
int |
getCurrentResult()
Returns the index of the current result set. |
int |
getCurrentResultInCache()
Returns the index in the cache of the current result set. |
int |
getMaximumResultsInCache()
Returns the maximum number of result sets the cache can contain at one time. |
StatementMetaData |
getMetaData()
Returns the StatementMetaData associated with the Statement's current result set. |
int |
getNumResults()
Returns the number of result sets fetched so far. |
int |
getNumResultsInCache()
Returns the number of result sets currently in the cache. |
java.lang.Object |
getParameter(int parameterNumber)
Returns the value of the parameter at the specified index. |
protected java.beans.PropertyChangeSupport |
getPropertyChange()
Accessor for the propertyChange field. |
SelectResult |
getResult()
Returns the current SelectResult for this CallableStatement (if the stored procedure returned any result sets). |
StatementMetaData |
getRootMetaData()
Returns the root StatementMetaData associated with the Statement. |
protected void |
initialize()
Initialize the object. |
boolean |
isFillResultCacheOnExecute()
Returns true if as many result sets as allowed are fetched into the cache when execute is invoked. |
boolean |
isLastResult()
Returns true if the currentResult is the last one fetched and either there are known to be no more result sets or the statement has been closed. |
void |
lastResult()
Applies any changes in the current row of the current result set to the database, and then positions to the last result set. |
void |
nextResult()
Applies any changes in the current row of the current result set to the database, and then positions to the next result set. |
void |
previousResult()
Applies any changes in the current row of the current result set to the database, and then positions to the previous result set. |
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()
Re-executes the SQL statement, refreshing any result sets it returned. |
protected void |
refreshResultTable()
This method was created in VisualAge. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener to the PropertyChange event set. |
void |
setCurrentResult(int resultNumber)
Applies any changes in the current row to the database, and then positions to the specified result set. |
protected void |
setCurrentResultInCache(int currentResultInCache)
Sets the currentResultInCache property (int) value. |
void |
setFillResultCacheOnExecute(boolean fillResultCacheOnExecute)
If true, as many result sets as allowed are fetched into the cache when execute is invoked. |
void |
setMaximumResultsInCache(int maximumResultsInCache)
Sets the maximum number of result sets the cache can contain at one time. |
void |
setMetaData(StatementMetaData metaData)
Associates a chain of StatementMetaData objects with the Statement. |
void |
setParameter(int parameterNumber,
java.lang.Object aValue)
Sets the parameter at the specified index to the specified value. |
protected void |
validateSQL()
|
Methods inherited from class java.lang.Object |
|
Field Detail |
protected int fieldNumResults
protected int fieldNumResultsInCache
protected int fieldCurrentResult
protected int fieldCurrentResultInCache
protected int fieldMaximumResultsInCache
protected java.util.Vector fieldResult
protected java.util.Vector fieldMetaDataVector
protected boolean fieldFillResultCacheOnExecute
protected transient boolean moreResults
protected transient boolean nextOrPrev
protected boolean describeAtRuntime
protected boolean[] outputParameterFetched
static final long serialVersionUID
private static final java.lang.String copyright
Constructor Detail |
public CallableStatement()
public CallableStatement(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 can 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 addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- PropertyChangeListener
removePropertyChangeListener(java.beans.PropertyChangeListener)
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 CallableStatement 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 createResultTable() throws DataException
protected void disconnect()
public void execute() throws DataException
The events aboutToExecute
and executed
are
triggered by this method.
The event cacheRowsChanged
of any associated SelectResults is triggered
by this method.
The event propertyChange
is triggered by this method for the
bound properties currentRow, currentRowInCache, currentResult, and currentResultInCache.
DatabaseConnection
,
StatementMetaData
,
SelectResult
protected void fetchFirstResult() throws DataException
protected void fetchNextResult() throws DataException
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
public void firstResult() throws DataException
If the first result set has been displaced from the cache, you are positioned to the first result set still in the cache, and an exception is thrown to indicate that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true),
the current row of the new current result set is locked in the database.
The event propertyChange
is triggered by this method for the
bound properties currentResultSet and currentResultSetInCache.
setCurrentResult(int)
public SelectResult getCacheResultAt(int resultNumber)
public int getCurrentResult()
Certain methods on CallableStatement, such as getResult
and
isLastResult
, apply to the current result set.
setCurrentResult(int)
public int getCurrentResultInCache()
The value of currentResultInCache and currentResult will be the same unless you have set maximumResultsInCache to a value other than 0, and a result set has been displaced from the cache. For example, if one result set has been displaced from the cache and currentResult is 2, currentResultInCache would be 1.
public int getMaximumResultsInCache()
setMaximumResultsInCache(int)
public StatementMetaData getMetaData()
setMetaData(com.ibm.db.StatementMetaData)
public int getNumResults()
public int getNumResultsInCache()
public java.lang.Object getParameter(int parameterNumber) throws DataException
After you execute a stored procedure, its output parameter values are not retrieved from the database until you request them via this method. When you first request these values, your statement must still be open. The reason for deferring the retrieval of these output values from the database is to allow you to first obtain any of the result sets returned by the stored procedure. Some database products may have problems if you get output parameter values before you obtain the result sets.
parameterNumber
- index of the parametersetParameter(int, java.lang.Object)
protected java.beans.PropertyChangeSupport getPropertyChange()
public SelectResult getResult()
A CallableStatement can have more than one SelectResult associated with it, one of which is considered the current result.
getCurrentResult()
,
setCurrentResult(int)
public StatementMetaData getRootMetaData()
getMetaData()
,
setMetaData(com.ibm.db.StatementMetaData)
protected void initialize()
public boolean isFillResultCacheOnExecute()
execute
is invoked.
Returns false if result sets are fetched into the cache only as needed to satisfy
a request to set the current result set position.
The number of result sets you are allowed to fetch into the cache is limited by the maximumResultsInCache property.
If more than one result set is fetched on execute
, all result sets
before the last one fetched are closed. You will not be able to fetch any additional rows
into the closed result sets beyond what was initially fetched when
execute
was invoked. The number of rows initially fetched for each
result set is governed by the fillCacheOnExecute property.
execute
, else false.setFillResultCacheOnExecute(boolean)
,
getMaximumResultsInCache()
,
SelectStatement.isFillCacheOnExecute()
public boolean isLastResult()
public void lastResult() throws DataException
The database operation which tells us that there are no more result sets has the
effect of closing the last result set. Therefore, after you use the lastResult
method, no more rows can be fetched in any of the result sets. Because of this, you
should generally avoid the method unless you are not limiting the cache size for
each result set, and the fillCacheOnExecute property is set to true,
causing all rows in each result set to be fetched as soon as the result set is opened.
If the current row should be locked ( isLockRows
returns true),
the current row of the new current result set is locked in the database.
The event propertyChange
is triggered by this method for the
bound properties currentResultSet and currentResultSetInCache.
setCurrentResult(int)
,
SelectStatement.setFillCacheOnExecute(boolean)
public void nextResult() throws DataException
If the next result set has not already been fetched from the database, it is fetched.
If no more result sets can be fetched, your position does not change, and
no exception is thrown. Thus, if you are on the last result set, repeatedly invoking
this method has no effect. For a discussion of when no more result sets can be fetched,
see the isLastResult
method.
If the current row should be locked ( isLockRows
returns true),
the current row of the new current result set is locked in the database.
The event propertyChange
is triggered by this method for the
bound properties currentResultSet and currentResultSetInCache.
setCurrentResult(int)
public void previousResult() throws DataException
If you are already on the first result set, your position does not change, and no exception is thrown. Thus, if you are on the first result set, repeatedly invoking this method has no effect.
If the previous result set has been displaced from the cache, your position does not change, and an exception is thrown to indicate that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true),
the current row of the new current result set is locked in the database.
The event propertyChange
is triggered by this method for the
bound properties currentResultSet and currentResultSetInCache.
setCurrentResult(int)
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- ObjectInputStreampublic void refresh() throws DataException
execute
method.
The events aboutToExecute
and executed
are
triggered by this method.
The event cacheRowsChanged
of any associated SelectResults
is triggered by this method.
The event propertyChange
is triggered by this method for the
bound properties currentRow, currentRowInCache, currentResult, and currentResultInCache.
execute()
protected void refreshResultTable() throws DataException
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- PropertyChangeListener
addPropertyChangeListener(java.beans.PropertyChangeListener)
public void setCurrentResult(int resultNumber) throws DataException
If the specified result set has not yet been fetched, result sets are fetched until the specified result set is in the cache or no more result sets can be fetched. If no more result sets can be fetched, and the specified result set was not reached, you are positioned to the last result set, and an exception is thrown to indicate that the request could not be satisfied.
If the specified result set has been displaced from the cache, you are positioned to the first result set in the cache, and an exception is thrown to indicate that the request could not be satisfied.
If the current row should be locked ( isLockRows
returns true),
the current row of the new current result set is locked in the database.
The event propertyChange
is triggered by this method for the
bound properties currentResultSet and currentResultSetInCache.
resultNumber
- index of the result set
getCurrentResult()
protected void setCurrentResultInCache(int currentResultInCache)
currentResultInCache
- The new value for the property.getCurrentResultInCache()
public void setFillResultCacheOnExecute(boolean fillResultCacheOnExecute)
execute
is invoked.
Otherwise, result sets are fetched into the cache as needed to satisfy
a request to set the current result set position.
The number of result sets you are allowed to fetch into the cache is limited by the maximumResultsInCache property.
If more than one result set is fetched on execute
, all result sets
before the last one fetched are closed. You will not be able to fetch any additional rows
into the closed result sets beyond what was initially fetched when
execute
was invoked. The number of rows initially fetched for each
result set is governed by the fillCacheOnExecute property.
If you never execute this method for a CallableStatement, the value defaults to true.
fillResultCacheOnExecute
- true, fetch as many result sets as allowed on
execute
; false fetch result sets only as neededisFillResultCacheOnExecute()
,
setMaximumResultsInCache(int)
,
SelectStatement.setFillCacheOnExecute(boolean)
public void setMaximumResultsInCache(int maximumResultsInCache)
If you never execute this method, the value defaults to 0.
maximumResultsInCache
- the maximum number of result sets in cachegetMaximumResultsInCache()
public void setMetaData(StatementMetaData metaData)
If the stored procedure returns no result sets, do not chain any StatementMetaData objects after the first one. If the stored procedure returns one result set, or returns multiple result sets which can all be described by the same meta data, chain only one StatementMetaData after the first one. If the stored procedure returns multiple result sets which cannot all be described by the same meta data, chain one StatementMetaData for each result set after the first one.
To chain StatementMetaData objects, use the setNextMetaData
method of
StatementMetaData.
metaData
- the first associated StatementMetaDatagetMetaData()
,
getRootMetaData()
,
StatementMetaData.setNextMetaData(com.ibm.db.StatementMetaData)
public void setParameter(int parameterNumber, java.lang.Object aValue) throws DataException
parameterNumber
- index of the parameteraValue
- parameter valuegetParameter(int)
protected void validateSQL() throws DataException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |