|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.db.beans.DBStatement | +--com.ibm.db.beans.DBModify
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.
Field Summary |
---|
Fields inherited from class com.ibm.db.beans.DBStatement |
---|
LEVEL_CONNECTION, LEVEL_RESULTSET, LEVEL_STATEMENT, TRANSACTION_DEFAULT |
Constructor Summary | |
---|---|
DBModify()
Default constructor for a DBModify bean. |
Method Summary | |
---|---|
void |
addDBAfterListener(com.ibm.db.beans.DBAfterListener listener)
Adds a listener to the DBAfter event set. |
void |
addDBBeforeListener(com.ibm.db.beans.DBBeforeListener listener)
Adds a listener to the DBBefore event set. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
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 resourceLevel)
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 resourceLevel)
Returns true if the JDBC resource at the specified level is open, otherwise returns false. |
void |
reExecute()
Re-executes the statement. |
void |
removeDBAfterListener(com.ibm.db.beans.DBAfterListener listener)
Removes a listener to the DBAfter event set. |
void |
removeDBBeforeListener(com.ibm.db.beans.DBBeforeListener listener)
Removes a listener to the DBBefore event set. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener to the PropertyChange event set. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DBModify()
Method Detail |
public void addDBAfterListener(com.ibm.db.beans.DBAfterListener listener)
addDBAfterListener
in class DBStatement
listener
- DBAfterListenerDBAfterListener
,
removeDBAfterListener(com.ibm.db.beans.DBAfterListener)
public void addDBBeforeListener(com.ibm.db.beans.DBBeforeListener listener)
addDBBeforeListener
in class DBStatement
listener
- DBBeforeListenerDBBeforeListener
,
removeDBBeforeListener(com.ibm.db.beans.DBBeforeListener)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in class DBStatement
listener
- PropertyChangeListenerremovePropertyChangeListener(java.beans.PropertyChangeListener)
public void close() throws DBException, java.sql.SQLException
autoCommit
is false, you must explicitly do a commit or
rollback before using the close method.
close
in class DBStatement
java.sql.SQLException
- if a database access error occurs
DBException
close(int)
,
isOpen()
public void close(int resourceLevel) throws DBException, java.sql.SQLException
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, you must explicitly do a commit or rollback before using
the close method.
close
in class DBStatement
resourceLevel
- LEVEL_STATEMENT indicates Statement
resources should be released. LEVEL_CONNECTION indicates
Connection and Statement resources should be released.
DBException
- invalidResourceLevel
- if the resource level is not valid
java.sql.SQLException
- if a database access error occursclose()
,
isOpen(int)
public void execute() throws DBException, java.sql.SQLException
execute
in class DBStatement
DBException
- badUidPwd
- if incorrect Userid or password specified
DBException
- noSQL
- if the SQL statement is null
DBException
- noTransactions
- if database does not support transactions and autoCommit set to false
java.sql.SQLException
- - if a database access error occurredpublic int getUpdateCount()
public boolean isOpen() throws java.sql.SQLException
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
in class DBStatement
java.sql.SQLException
close()
public boolean isOpen(int resourceLevel) throws DBException, java.sql.SQLException
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.
isOpen
in class DBStatement
resourceLevel
- A resource level: LEVEL_CONNECTION,
LEVEL_STATEMENT.
DBException
- invalidResourceLevel
- if the resource level is not valid
java.sql.SQLException
- if a database-access error occurs.close(int)
public void reExecute() throws DBException, java.sql.SQLException
execute
method.
reExecute
in class DBStatement
DBException
- noActiveConnection
- if no active connection exists
DBException
- notOpen
- if the statement is not open
java.sql.SQLException
- - if a database access error occurredexecute()
public void removeDBAfterListener(com.ibm.db.beans.DBAfterListener listener)
removeDBAfterListener
in class DBStatement
listener
- DBAfterListenerDBAfterListener
,
addDBAfterListener(com.ibm.db.beans.DBAfterListener)
public void removeDBBeforeListener(com.ibm.db.beans.DBBeforeListener listener)
removeDBBeforeListener
in class DBStatement
listener
- DBBeforeListenerDBBeforeListener
,
addDBBeforeListener(com.ibm.db.beans.DBBeforeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in class DBStatement
listener
- PropertyChangeListeneraddPropertyChangeListener(java.beans.PropertyChangeListener)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |