|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent com.ibm.as400.vaccess.SQLResultSetFormPane
public class SQLResultSetFormPane extends JComponent implements Serializable
The SQLResultSetFormPane class represents a form that is filled in with the result set generated by a SQL query using JDBC. The form displays one record of the result set at a time and provides buttons that allow the user to scroll forward, backward, to the first or last record, or refresh the view of the result set.
The data in the form is retrieved from the system (and the GUI fields for the data are created) when load() is called. If load() is not called, the form will be empty.
It is up to the user to register a JDBC driver when using this class. For example, the following code registers the IBM Toolbox for Java JDBC driver.
DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
Users should call close() to ensure that the result set is closed when this table is no longer needed. close() should also be called on the SQLConnection object as well to close the connection.
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.
SQLResultSetFormPane objects generate the following events:
// Register JDBC driver. DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ()); // Set up table for result set contents. final SQLConnection connection = new SQLConnection("jdbc:as400://MySystem", "Userid", "Password"); String query = "SELECT * FROM MYLIB.MYTABLE"; final SQLResultSetFormPane pane = new SQLResultSetFormPane(connection, query); // Set up window to hold table JFrame frame = new JFrame ("My Window"); WindowListener l = new WindowAdapter() { // Close the pane when window is closed. public void windowClosing(WindowEvent e) { pane.close(); connection.close(); } }; frame.addWindowListener(l); // Set up the error dialog adapter. pane.addErrorListener (new ErrorDialogAdapter (frame)); // Add the component and get data from system. frame.getContentPane().add(pane); pane.load(); // Display the window frame.setVisible(true)
Modifier and Type | Class and Description |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Modifier and Type | Field and Description |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor and Description |
---|
SQLResultSetFormPane()
Deprecated. Constructs a SQLResultSetFormPane object. |
SQLResultSetFormPane(SQLConnection connection,
String query)
Deprecated. Constructs a SQLResultSetFormPane object. |
Modifier and Type | Method and Description |
---|---|
void |
addActionCompletedListener(ActionCompletedListener listener)
Deprecated. Adds a listener to be notified when a new record is displayed. |
void |
addErrorListener(ErrorListener listener)
Deprecated. Adds a listener to be notified when an error occurs. |
void |
clearWarnings()
Deprecated. Clears all SQL warnings. |
void |
close()
Deprecated. Closes the SQL result set this form represents. |
void |
displayFirst()
Deprecated. Displays the first record of the result set. |
void |
displayLast()
Deprecated. Displays the last record of the result set. |
void |
displayNext()
Deprecated. Displays the next record of the result set. |
void |
displayPrevious()
Deprecated. Displays the previous record of the result set. |
SQLConnection |
getConnection()
Deprecated. Returns the SQL connection with which to access data. |
int |
getCurrentRecord()
Deprecated. Returns the index of the record currently being displayed. |
String |
getLabelText(int index)
Deprecated. Returns the text of the label at the given index. |
String |
getQuery()
Deprecated. Returns the SQL query used to generate the form data. |
String |
getStringValueAt(int index)
Deprecated. Returns the string value of the current record at the given index. |
Object |
getValueAt(int index)
Deprecated. Returns the value of the current record at the given index. |
SQLWarning |
getWarnings()
Deprecated. Returns the warnings generated by the JDBC connection, statement, and result set. |
void |
load()
Deprecated. Refreshes the view based on the state of the system. |
void |
removeActionCompletedListener(ActionCompletedListener listener)
Deprecated. Removes a listener from being notified when a new record is displayed. |
void |
removeErrorListener(ErrorListener listener)
Deprecated. Removes a listener from being notified when an error occurs. |
void |
setConnection(SQLConnection connection)
Deprecated. Sets the SQL connection with which to access data. |
void |
setLabelText(int index,
String text)
Deprecated. Sets the text of the label at the given index. |
void |
setQuery(String query)
Deprecated. Sets the SQL query used to generate the result set. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SQLResultSetFormPane()
public SQLResultSetFormPane(SQLConnection connection, String query)
connection
- The SQL connection.query
- The SQL query.Method Detail |
---|
public void addActionCompletedListener(ActionCompletedListener listener)
listener
- The listener.public void addErrorListener(ErrorListener listener)
listener
- The listener.public void clearWarnings()
public void close()
public void displayFirst()
public void displayLast()
public void displayNext()
public void displayPrevious()
public SQLConnection getConnection()
public int getCurrentRecord()
public String getLabelText(int index)
index
- The index of the label. Indices start at 0.public String getQuery()
public String getStringValueAt(int index)
index
- The index of the value. Indices start at 0.public Object getValueAt(int index)
index
- The index of the value. Indices start at 0.public SQLWarning getWarnings()
public void load()
public void removeActionCompletedListener(ActionCompletedListener listener)
listener
- The listener.public void removeErrorListener(ErrorListener listener)
listener
- The listener.public void setConnection(SQLConnection connection) throws PropertyVetoException
connection
- The SQL connection.PropertyVetoException
- If the change is vetoed.public void setLabelText(int index, String text)
index
- The index of the label. Indices start at 0.text
- The text of the label.public void setQuery(String query) throws PropertyVetoException
query
- The SQL query.PropertyVetoException
- If the change is vetoed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |