Where Am I? Class Hierarchy All Classes All Fields and Methods

Class com.ibm.ivj.db.uibeans.Modify

java.lang.Object
   |
   +----com.ibm.ivj.db.uibeans.Statement
           |
           +----com.ibm.ivj.db.uibeans.Modify

public class Modify
implements Serializable, DatabaseConnectionAfterListener, DatabaseConnectionBeforeListener, StatementAfterListener, StatementBeforeListener
extends Statement

Modify allows you to insert, update, or delete data in a relational database using JDBC.


Constructor Index

Modify()
Constructs a new Modify and initializes properties to the default values.

Method Index

cancelAction()
Cancels execution of the SQL statement which is associated with this Modify.
commit()
Commits changes to the database.
connect()
Attempts to establish a connection to the database using the connection properties specified in the action property.
disconnect()
Closes the JDBC connection for further use by this Modify object.
execute()
Executes the SQL statement in the associated SQL specification.
getAction()
Returns a new Query object that contains references to the connection alias and the SQL specification for this Modify.
getInstanceBeanInfo()
Returns the BeanInfo that contains information about the instance properties of this Modify.
getNumAffectedRows()
Returns the number of rows that were affected by executing the SQL statement.
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.
getSQLStatement()
Returns the underlying com.ibm.db.SQLStatement.
getStatementMetaData()
Returns the underlying com.ibm.db.StatementMetaData.
getTimeout()
Returns the number of seconds the JDBC driver will wait for this statement to execute.
isExecuted()
Returns true if execute has been invoked.
propertyChange(PropertyChangeEvent)
Method to handle events for the PropertyChangeListener interface.
rollback()
Rollback changes in the database.
setAction(Query)
Sets the connection alias and the SQL specification for this Modify to the values contained in the specified Query.
setDatabaseConnection(DatabaseConnection)
Associates a DatabaseConnection with this Modify.
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.
setStatementMetaData(StatementMetaData)
Associates a StatementMetaData with this Modify.
setTimeout(int)
Sets the number of seconds the JDBC driver will wait for this statement to execute.

Constructors

Modify
 public Modify() 
Constructs a new Modify and initializes properties to the default values.


Methods

cancelAction
 public void cancelAction() throws DataException
Cancels execution of the SQL statement which is associated with this Modify. In order to use this method, it must be invoked from a thread different from the one in which the SQL statement is running.

Throws: DataException
noConnection - if no associated DatabaseConnection
Throws: DataException
notExecuting - if the statement is not currently being executed
Throws: DataException
sqlException - if an SQLException occurred
Overrides:
cancelAction in class Statement
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 turned off.

The events aboutToCommit and committed are triggered by this method.

Throws: DataException
noActiveConnection - if no active connection exists
Throws: DataException
sqlException - if an SQL exception occurs
See Also:
setAutoCommit
rollback
connect
 public void connect() throws DataException
Attempts to establish a connection to the database using the connection properties specified in the action 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.

If the connectionPoolType property is POOL_TYPE_WEBSPHERE, the connection is obtained from the WebSphere connection pools. If no connection pool currently exists, a new connection pool with default settings is created based on the specified URL. Then the connection is obtained from the new pool.

If the connectionPoolType property is POOL_TYPE_NONE, a new connection is obtained directly from the JDBC DriverManager.

The events aboutToConnect and connected are triggered by this method.

Throws: DataException
alreadyConnected - if connection is already established
Throws: DataException
noGui - if no GUI available and logon prompt requested
Throws: DataException
badUidPwd - if incorrect Userid or password specified
Throws: DataException
noTransactions - if database does not support transactions and autoCommit set to false
Throws: DataException
sqlException - if an SQLException occurred
Throws: DataException
websphereConnectionError - if an error occurred obtaining the connection from WebSphere
See Also:
disconnect
disconnect
 public void disconnect() throws DataException
Closes the JDBC connection for further use by this Modify object. A disconnect may or may not be performed on the JDBC connection itself depending on whether the JDBC connection was obtained from a WebSphere connection pool, whether it is externally managed, and if neither of the former applies, whether it is being shared by another object using the same connection alias.

If the connection is externally managed or is being shared by another object, the association between the JDBC connection and this object is removed, but the JDBC connection itself is not closed.

If the connection was obtained from a Webshpere connection pool and is not externally managed, the JDBC connection is simply released back to the connection pool.

If the connection is not externally managed, is not from a Webshpere connection pool, and is not being shared with another object, the JDBC connection is closed, releasing the JDBC resources associated with the connection.

The events aboutToDisconnect and disconnected are triggered by this method.

Throws: DataException
noActiveConnection - if no active Connection
Throws: DataException
notRegistered - if connection alias not registered as in use
Throws: DataException
sqlException - if an SQLException occurred
Throws: DataException
websphereConnectionError - if an error occurred releasing the connection to WebSphere
See Also:
connect
execute
 public void execute() throws DataException
Executes the SQL statement in the associated SQL specification. 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.

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
noTransactions - if database does not support transactions and autoCommit set to false
Throws: DataException
sqlException - if an SQLException occurred
Overrides:
execute in class Statement
getAction
 public Query getAction() 
Returns a new Query object that contains references to the connection alias and the SQL specification for this Modify.

Returns:
a new Query
See Also:
setAction
getInstanceBeanInfo
 public BeanInfo getInstanceBeanInfo() 
Returns the BeanInfo that contains information about the instance properties of this Modify. This method is called by the VisualAge for Java IDE to display the parameters for the SQL statement on the connection dialog.

Returns:
beanInfo of instance properties
getNumAffectedRows
 public int getNumAffectedRows() 
Returns the number of rows that were affected by executing the SQL statement. For an INSERT statement, this is the number of rows inserted, for a DELETE, the number of rows deleted, and for an UPDATE, the number of rows updated.

Returns:
the number of affected rows
getParameter
 public Object getParameter(int parameterNumber) throws DataException
Returns the value of the parameter at the specified index. 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:
the parameter value
Throws: IndexOutOfBoundsException
if the parameter index is not defined
Throws: DataException
sqlException - if an SQL Exception is raised (only thrown by ProcedureCall)
Overrides:
getParameter in class Statement
See Also:
getParameterToString
setParameter
getParameter
 public Object getParameter(String parameterName) throws DataException
Returns the value of the parameter with the specified name. If the parameter value is null, a null is returned.

Parameters:
parameterName - name of the parameter
Returns:
the parameter value
Throws: IndexOutOfBoundsException
if the parameter name is not defined
Throws: DataException
sqlException - if an SQL Exception is raised (only thrown by ProcedureCall)
Overrides:
getParameter in class Statement
See Also:
getParameterToString
setParameter
getParameterToString
 public String getParameterToString(int parameterNumber) throws DataException
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
Throws: DataException
sqlException - if an SQL Exception is raised (only thrown by ProcedureCall)
Overrides:
getParameterToString in class Statement
See Also:
getParameter
setParameterFromString
getParameterToString
 public String getParameterToString(String parameterName) throws DataException
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
Throws: DataException
sqlException - if an SQL Exception is raised (only thrown by ProcedureCall)
Overrides:
getParameterToString in class Statement
See Also:
getParameter
setParameterFromString
getSQLStatement
 public SQLStatement getSQLStatement() 
Returns the underlying com.ibm.db.SQLStatement.

Returns:
the associated SQLStatement.
getStatementMetaData
 public StatementMetaData getStatementMetaData() 
Returns the underlying com.ibm.db.StatementMetaData.

Returns:
the associated StatementMetaData
Overrides:
getStatementMetaData in class Statement
See Also:
setStatementMetaData
getTimeout
 public int getTimeout() 
Returns the number of seconds the JDBC driver will wait for this statement to execute. If the limit is exceeded, a DataException is thrown by the execute method.

Returns:
the timeout limit in seconds; zero means unlimited
Overrides:
getTimeout in class Statement
See Also:
setTimeout
isExecuted
 public boolean isExecuted() 
Returns true if execute has been invoked.

Returns:
true if execute has been invoked. otherwise false.
propertyChange
 public void propertyChange(PropertyChangeEvent arg1) 
Method to handle events for the PropertyChangeListener interface.

Parameters:
arg1 - java.beans.PropertyChangeEvent
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 turned off.

The events aboutToRollback and rolledBack are triggered by this method.

Throws: DataException
noActiveConnection - if no active connection exists
Throws: DataException
sqlException - if an SQL exception occurs
See Also:
commit
setAutoCommit
setAction
 public void setAction(Query query) 
Sets the connection alias and the SQL specification for this Modify to the values contained in the specified Query. The Query itself is not saved.

Parameters:
query - the Query
See Also:
getAction
setDatabaseConnection
 public void setDatabaseConnection(DatabaseConnection connection) 
Associates a DatabaseConnection with this Modify.

Parameters:
connection - the associated DatabaseConnection
Overrides:
setDatabaseConnection in class Statement
See Also:
getDatabaseConnection
setParameter
 public void setParameter(int parameterNumber,
                          Object aValue) throws DataException
Sets the parameter at the specified index to the specified value. To set a parameter value to null, pass null as the 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
wrongObjectType - if the value does not match the object type of the parameter
Overrides:
setParameter in class Statement
See Also:
setParameterFromString
getParameter
setParameter
 public void setParameter(String parameterName,
                          Object aValue) throws DataException
Sets the parameter with the specified name to the specified value. To set a parameter value to null, pass null as the value.

Parameters:
parameterName - name of the parameter
aValue - parameter value
Throws: IndexOutOfBoundsException
if the parameter name is not defined
Throws: DataException
wrongObjectType - if the value does not match the object type of the parameter
Overrides:
setParameter in class Statement
See Also:
setParameterFromString
getParameter
setParameterFromString
 public void setParameterFromString(int parameterNumber,
                                    String stringValue) throws DataException
Sets the parameter at the specified index to the specified value. The index of the first parameter is 1.

The stringValue is converted to the datatype associated with the parameter before the parameter is updated. To set a parameter value to null, pass null as the value. If the datatype is not String, you can also set a parameter value to null by passing a zero-length String as the value.

Parameters:
parameterNumber - index of the parameter
stringValue - parameter value as a String
Throws: IndexOutOfBoundsException
if the parameter index is not defined
Throws: DataException
wrongObjectType - if the value does not match the object type of the parameter
Overrides:
setParameterFromString in class Statement
See Also:
setParameter
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. To set a parameter value to null, pass null as the value. If the datatype is not String, you can also set a parameter value to null by passing a zero-length String as the value.

Parameters:
parameterName - name of the parameter
stringValue - parameter value as a String
Throws: IndexOutOfBoundsException
if the parameter name is not defined
Throws: DataException
wrongObjectType - if the value does not match the object type of the parameter
Overrides:
setParameterFromString in class Statement
See Also:
setParameter
getParameterToString
setStatementMetaData
 public void setStatementMetaData(StatementMetaData metaData) 
Associates a StatementMetaData with this Modify.

Parameters:
metaData - the associated StatementMetaData
Overrides:
setStatementMetaData in class Statement
See Also:
getStatementMetaData
setTimeout
 public void setTimeout(int seconds) 
Sets the number of seconds the JDBC driver will wait for this statement to execute. If the limit is exceeded, a DataException is thrown by the execute method.

Parameters:
seconds - the new timeout limit in seconds; zero means unlimited
Overrides:
setTimeout in class Statement
See Also:
getTimeout

Where Am I? Class Hierarchy All Classes All Fields and Methods