Class Hierarchy All Classes All Fields and Methods
Class com.ibm.db.beans.DBModify
java.lang.Object com.ibm.db.beans.DBStatement com.ibm.db.beans.DBModifypublic class DBModify
extends DBStatementThis class allows you to execute an SQL insert, update, or delete in a bean which exposes JDBC 2.0 RowSet functionality and adds its own useful functions.
The JDBC RowSet "wraps" a connection, a statement, and a result set as a bean, and provides properties, methods, and events for using them. The DBModify bean is for executing statements that do not return result sets. Therefore, it does not expose RowSet functionality for dealing with result sets. However, much of the RowSet interface deals with setting database connection properties, setting parameters, and executing the statement, and this function is exposed.
This class also adds function to get the update count from an insert, update, or delete.
Constructor Index Constructor Description DBModify() Default constructor for a DBModify bean.
Method Index Method Description void addDBAfterListener(DBAfterListener) Adds a listener to the DBAfter event set. void addDBBeforeListener(DBBeforeListener) Adds a listener to the DBBefore event set. void addPropertyChangeListener(PropertyChangeListener) Adds a listener to the PropertyChange event set. void close() Releases the underlying database connection and statement immediately instead of waiting for this to happen when the object is finalized. void close(int) Releases the underlying database and JDBC resources immediately instead of waiting for this to happen when the object is finalized. void execute() Executes the SQL statement, connecting to the database if not already connected. int getUpdateCount() Returns either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing. boolean isOpen() Returns true if the underlying java.sql.Connection and java.sql.Statement are open, otherwise returns false. boolean isOpen(int) Returns true if the JDBC resource at the specified level is open, otherwise returns false. void reExecute() Re-executes the statement. void removeDBAfterListener(DBAfterListener) Removes a listener to the DBAfter event set. void removeDBBeforeListener(DBBeforeListener) Removes a listener to the DBBefore event set. void removePropertyChangeListener(PropertyChangeListener) Removes a listener to the PropertyChange event set.
Constructors
DBModify
public DBModify()Default constructor for a DBModify bean. This constructor also creates associated bean of type DBParameterMetaData.
Methods
addDBAfterListener
public synchronized void addDBAfterListener(DBAfterListener listener)Adds a listener to the DBAfter event set. DBAfter events occur after significant actions have been completed via the DBModify.
- Parameters
- listener - DBAfterListener
- Overrides
- addDBAfterListener in class DBStatement
- See Also
addDBBeforeListener
public synchronized void addDBBeforeListener(DBBeforeListener listener)Adds a listener to the DBBefore event set. DBBefore events occur before significant actions have been completed via the DBModify.
- Parameters
- listener - DBBeforeListener
- Overrides
- addDBBeforeListener in class DBStatement
- See Also
addPropertyChangeListener
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)Adds a listener to the PropertyChange event set.
- Parameters
- listener - PropertyChangeListener
- Overrides
- addPropertyChangeListener in class DBStatement
- See Also
close
public void close() throws DBException, SQLExceptionReleases the underlying database connection and statement immediately instead of waiting for this to happen when the object is finalized. If autoCommit is false, explicitly do a commit or rollback before using the close method.
- Throws
- SQLException if a database access error occurs
- Overrides
- close in class DBStatement
close
public void close(int resourceLevel) throws DBException, SQLExceptionReleases the underlying database and JDBC resources immediately instead of waiting for this to happen when the object is finalized.
The JDBC resources that may be released include the Statement, and the Connection. The value of the resourceLevel parameter determines which resources are released. If all resources, including the Connection, are released, and autoCommit is false, explicitly do a commit or rollback before using the close method.
- Parameters
- resourceLevel - LEVEL_STATEMENT indicates Statement resources should be released. LEVEL_CONNECTION indicates Connection and Statement resources should be released.
- Throws
- DBException invalidResourceLevel - if the resource level is not valid
- Throws
- SQLException if a database access error occurs
- Overrides
- close in class DBStatement
execute
public synchronized void execute() throws DBException, SQLExceptionExecutes the SQL statement, connecting to the database if not already connected.
- Throws
- DBException badUidPwd - if incorrect Userid or password specified
- Throws
- DBException noSQL - if the SQL statement is null
- Throws
- DBException noTransactions - if database does not support transactions and autoCommit set to false
- Throws
- SQLException - if a database access error occurred
- Overrides
- execute in class DBStatement
getUpdateCount
public int getUpdateCount()Returns either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing.
- Returns
- int the number of rows affected by the statement
isOpen
public boolean isOpen() throws SQLExceptionReturns true if the underlying java.sql.Connection and java.sql.Statement are open, otherwise returns false.
When isOpen returns false, it may be because the statement has not been executed, the close method has been invoked, or the bean has been serialized and then de-serialized.
- Returns
- true if the bean is open, otherwise false.
- Overrides
- isOpen in class DBStatement
- See Also
isOpen
public boolean isOpen(int resourceLevel) throws DBException, SQLExceptionReturns true if the JDBC resource at the specified level is open, otherwise returns false.
If the resourceLevel is LEVEL_CONNECTION, a return value of true indicates that the Connection is open. If the resourceLevel is LEVEL_STATEMENT, a return value of true indicates that the Statement, and therefore also the Connection are open.
- Parameters
- resourceLevel - A resource level: LEVEL_CONNECTION, LEVEL_STATEMENT.
- Returns
- true if the JDBC resource at the specified level is open, otherwise false.
- Throws
- DBException invalidResourceLevel - if the resource level is not valid
- Throws
- SQLException if a database-access error occurs.
- Overrides
- isOpen in class DBStatement
- See Also
reExecute
public synchronized void reExecute() throws DBException, SQLExceptionRe-executes the statement. The DBModify must currently be open. Any changes you have made to statement parameters will take effect when the statement is re-executed. If you have changed the statement itself, that change will not take effect. (To make the latter change take effect, use the execute method.
- Throws
- DBException noActiveConnection - if no active connection exists
- Throws
- DBException notOpen - if the statement is not open
- Throws
- SQLException - if a database access error occurred
- Overrides
- reExecute in class DBStatement
- See Also
removeDBAfterListener
public synchronized void removeDBAfterListener(DBAfterListener listener)Removes a listener to the DBAfter event set. DBAfter events occur after significant actions have been completed via the DBSelect.
- Parameters
- listener - DBAfterListener
- Overrides
- removeDBAfterListener in class DBStatement
- See Also
removeDBBeforeListener
public synchronized void removeDBBeforeListener(DBBeforeListener listener)Removes a listener to the DBBefore event set. DBBefore events occur before significant actions have been completed via the DBSelect.
- Parameters
- listener - DBBeforeListener
- Overrides
- removeDBBeforeListener in class DBStatement
- See Also
removePropertyChangeListener
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)Removes a listener to the PropertyChange event set.
- Parameters
- listener - PropertyChangeListener
- Overrides
- removePropertyChangeListener in class DBStatement
- See Also
Class Hierarchy All Classes All Fields and Methods