All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.SQLStatementDocument

java.lang.Object
   |
   +----com.sun.java.swing.text.AbstractDocument
           |
           +----com.sun.java.swing.text.PlainDocument
                   |
                   +----com.ibm.as400.vaccess.SQLStatementDocument

public class SQLStatementDocument
extends PlainDocument
implements Serializable
The SQLStatementDocument class represents SQL statement that is issued when execute() is called.

It is up to the user to register a JDBC driver when using this class. For example, the following code registers the AS/400 Toolbox for Java JDBC driver.

DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());

Most errors are reported by firing ErrorEvents, rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.

SQLStatementDocument objects generate the following events:


Constructor Index

 o SQLStatementDocument()
Constructs a SQLStatementDocument object.
 o SQLStatementDocument(SQLConnection, String)
Constructs a SQLStatementDocument object.

Method Index

 o addActionCompletedListener(ActionCompletedListener)
Adds a listener to be notified when a SQL statement is executed.
 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o addWorkingListener(WorkingListener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.
 o execute()
Runs the contents of this document as a SQL statement.
 o getConnection()
Returns the SQL connection used to execute statements.
 o getMoreResults()
Makes the next result of the last statement run the current result.
 o getResultSet()
Returns the current results of the last SQL statement run.
 o getSQLStatement()
Returns the SQL statement that was last executed which the results in this object represent.
 o getUpdateCount()
Returns the number of rows affected by the last SQL statement run.
 o getWarnings()
Returns the warnings generated by the JDBC connection and statement.
 o removeActionCompletedListener(ActionCompletedListener)
Removes a listener from being notified when a SQL statement is issued.
 o removeErrorListener(ErrorListener)
Removes a listener from being notified when an error occurs.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from being notified when the value of any bound property is changed.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from being notified when the value of any constrained property is changed.
 o removeWorkingListener(WorkingListener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.
 o setConnection(SQLConnection)
Sets the SQL connection used to execute statements.

Constructors

 o SQLStatementDocument
 public SQLStatementDocument()
Constructs a SQLStatementDocument object.

 o SQLStatementDocument
 public SQLStatementDocument(SQLConnection connection,
                             String text)
Constructs a SQLStatementDocument object.

Parameters:
connection - The SQL connection.
text - The text for the document

Methods

 o addActionCompletedListener
 public void addActionCompletedListener(ActionCompletedListener listener)
Adds a listener to be notified when a SQL statement is executed. The listener's actionCompleted() method will be called.

Parameters:
listener - The listener.
 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs. The listener's errorOccurred() method will be called.

Parameters:
listener - The listener.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The listener's propertyChange() method will be called.

Parameters:
listener - The listener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The listener's vetoableChange() method will be called.

Parameters:
listener - The listener.
 o addWorkingListener
 public void addWorkingListener(WorkingListener listener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o execute
 public void execute()
Runs the contents of this document as a SQL statement.

 o getConnection
 public SQLConnection getConnection()
Returns the SQL connection used to execute statements.

Returns:
The SQL connection.
 o getMoreResults
 public void getMoreResults()
Makes the next result of the last statement run the current result. Nothing is done if no statement has been executed.

Refer to JDBC documentation for more information.

 o getResultSet
 public ResultSet getResultSet()
Returns the current results of the last SQL statement run. Multiple results can be obtained by calling getUpdateCount() and/or getResultSet() multiple times, with intervening getMoreResults() calls.

Refer to JDBC documentation for more information.

Returns:
The result set or null if the result was not a result set, or if there are no results.
 o getSQLStatement
 public String getSQLStatement()
Returns the SQL statement that was last executed which the results in this object represent.

Returns:
The SQL statement that the results in this object represent.
 o getUpdateCount
 public int getUpdateCount()
Returns the number of rows affected by the last SQL statement run. Multiple results can be obtained by calling getUpdateCount() and/or getResultSet() multiple times, with intervening getMoreResults() calls. If an error occurs, 0 is returned.

Refer to JDBC documentation for more information.

Returns:
The number of rows that were affected. If no rows were affected or the SQL statement was a DDL command, 0 is returned. If there are no results or the results are a result set, -1 is returned.
 o getWarnings
 public SQLWarning getWarnings()
Returns the warnings generated by the JDBC connection and statement. Each time the execute() is called (the SQL statement is run), the warnings are cleared. Connection warnings are only available after the first time a statement is executed. The warnings from the statement will be linked to the end of any connection warnings.

Returns:
The warnings generated by the connection and statement, or null if none.
 o removeActionCompletedListener
 public void removeActionCompletedListener(ActionCompletedListener listener)
Removes a listener from being notified when a SQL statement is issued.

Parameters:
listener - The listener.
 o removeErrorListener
 public void removeErrorListener(ErrorListener listener)
Removes a listener from being notified when an error occurs.

Parameters:
listener - The listener.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from being notified when the value of any bound property is changed.

Parameters:
listener - The listener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener from being notified when the value of any constrained property is changed.

Parameters:
listener - The listener.
 o removeWorkingListener
 public void removeWorkingListener(WorkingListener listener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o setConnection
 public void setConnection(SQLConnection connection) throws PropertyVetoException
Sets the SQL connection used to execute statements. This property is bound and constrained.

Parameters:
connection - The SQL connection.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index