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.DBModify

public class DBModify
extends DBStatement

This 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.

 

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.

 

addPropertyChangeListener

public synchronized void addPropertyChangeListener(PropertyChangeListener listener) 

Adds a listener to the PropertyChange event set.

 

close

public void close() throws DBException, SQLException

Releases 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.

 

close

public void close(int resourceLevel) throws DBException, SQLException

Releases 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.

 

execute

public synchronized void execute() throws DBException, SQLException

Executes the SQL statement, connecting to the database if not already connected.

 

getUpdateCount

public int getUpdateCount() 

Returns either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing.

 

isOpen

public boolean isOpen() throws SQLException

Returns 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.

 

isOpen

public boolean isOpen(int resourceLevel) throws DBException, SQLException

Returns 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.

 

reExecute

public synchronized void reExecute() throws DBException, SQLException

Re-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.

 

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.

 

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.

 

removePropertyChangeListener

public synchronized void removePropertyChangeListener(PropertyChangeListener listener) 

Removes a listener to the PropertyChange event set.

Class Hierarchy All Classes All Fields and Methods