All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.SQLResultSetTablePane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.ibm.as400.vaccess.SQLResultSetTablePane

public class SQLResultSetTablePane
extends JComponent
implements Serializable
The SQLResultSetTablePane class represents a table that contains the result set generated by a SQL query using JDBC.

The data in the table is retrieved from the system when load() is called. If load() is not called, the table 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 AS/400 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.

The data in this table is not editable, the individual cell values cannot be changed.

SQLResultSetTablePane 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("MySystem", "Userid", "Password");
String query = "SELECT * FROM MYLIB.MYTABLE";
final SQLResultSetTablePane pane = new SQLResultSetTablePane(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)


Constructor Index

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

Method Index

 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addListSelectionListener(ListSelectionListener)
Adds a listener to be notified when the selection changes.
 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 clearWarnings()
Clears all SQL warnings.
 o close()
Closes the SQL result set this table represents.
 o getColumnModel()
Returns the column model for this table.
 o getColumnTitle(int)
Returns the title of a column.
 o getColumnWidth(int)
Returns the width of a column.
 o getConnection()
Returns the SQL connection with which to access data.
 o getDataModel()
Returns the data model for the table.
 o getGridColor()
Returns the color used to draw grid lines.
 o getQuery()
Returns the SQL query used to generate the table data.
 o getSelectionModel()
Returns the ListSelectionModel that is used to maintain row selection state.
 o getShowHorizontalLines()
Returns whether horizontal lines are drawn between rows.
 o getShowVerticalLines()
Returns whether vertical lines are drawn between columns.
 o getStringValueAt(int, int)
Returns the string value at the specifed row and column.
 o getValueAt(int, int)
Returns the value at the specifed row and column.
 o getWarnings()
Returns the warnings generated by the JDBC connection, statement, and result set.
 o load()
Loads the table based on the state of the system.
 o refreshHeadings()
Updates the table header to match the result set data.
 o removeErrorListener(ErrorListener)
Removes a listener from being notified when an error occurs.
 o removeListSelectionListener(ListSelectionListener)
Removes a listener from being notified when the selection changes.
 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 setColumnTitle(int, String)
Sets the title of a column.
 o setColumnWidth(int, int)
Sets the width of a column.
 o setConnection(SQLConnection)
Sets the SQL connection with which to access data.
 o setGridColor(Color)
Sets the color used to draw grid lines.
 o setQuery(String)
Sets the SQL query used to build the table.
 o setSelectionModel(ListSelectionModel)
Sets the ListSelectionModel that is used to maintain row selection state.
 o setShowHorizontalLines(boolean)
Sets whether horizontal lines are drawn between rows.
 o setShowVerticalLines(boolean)
Sets whether vertical lines are drawn between columns.

Constructors

 o SQLResultSetTablePane
 public SQLResultSetTablePane()
Constructs a SQLResultSetTablePane object.

 o SQLResultSetTablePane
 public SQLResultSetTablePane(SQLConnection connection,
                              String query)
Constructs a SQLResultSetTablePane object.

Parameters:
connection - The SQL connection.
query - The SQL query.

Methods

 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs.

Parameters:
listener - The listener.
 o addListSelectionListener
 public void addListSelectionListener(ListSelectionListener listener)
Adds a listener to be notified when the selection changes.

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.

Parameters:
listener - The listener.
Overrides:
addPropertyChangeListener in class JComponent
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed.

Parameters:
listener - The listener.
Overrides:
addVetoableChangeListener in class JComponent
 o clearWarnings
 public void clearWarnings()
Clears all SQL warnings.

 o close
 public void close()
Closes the SQL result set this table represents.

 o getColumnModel
 public TableColumnModel getColumnModel()
Returns the column model for this table.

Returns:
Model for this table's columns.
 o getColumnTitle
 public String getColumnTitle(int columnIndex)
Returns the title of a column. This is used for the table column heading. If an error occurs, null is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The title of the column.
 o getColumnWidth
 public int getColumnWidth(int columnIndex)
Returns the width of a column. If an error occurs, 0 is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The width of the column.
 o getConnection
 public SQLConnection getConnection()
Returns the SQL connection with which to access data.

Returns:
The SQL connection.
 o getDataModel
 public SQLResultSetTableModel getDataModel()
Returns the data model for the table.

Returns:
The data model for the table.
 o getGridColor
 public Color getGridColor()
Returns the color used to draw grid lines.

Returns:
The color used to draw grid lines.
 o getQuery
 public String getQuery()
Returns the SQL query used to generate the table data.

Returns:
The SQL query.
 o getSelectionModel
 public ListSelectionModel getSelectionModel()
Returns the ListSelectionModel that is used to maintain row selection state.

Returns:
The model that provides row selection state.
 o getShowHorizontalLines
 public boolean getShowHorizontalLines()
Returns whether horizontal lines are drawn between rows.

Returns:
true if horizontal lines are to be drawn; false otherwise.
 o getShowVerticalLines
 public boolean getShowVerticalLines()
Returns whether vertical lines are drawn between columns.

Returns:
true if vertical lines are to be drawn; false otherwise.
 o getStringValueAt
 public String getStringValueAt(int rowIndex,
                                int columnIndex)
Returns the string value at the specifed row and column. Indices start at 0. If an error occurs, null is returned.

Parameters:
rowIndex - The row index.
columnIndex - The column index.
Returns:
The value at the specified row and column as a string.
 o getValueAt
 public Object getValueAt(int rowIndex,
                          int columnIndex)
Returns the value at the specifed row and column. Indices start at 0. If an error occurs, null is returned.

Parameters:
rowIndex - The row index.
columnIndex - The column index.
Returns:
The value at the specified row and column.
 o getWarnings
 public SQLWarning getWarnings()
Returns the warnings generated by the JDBC connection, statement, and result set. The warnings from the result set will be linked to the end of any statement warnings, which in turn are linked to the end of any connection warnings. Warnings are cleared when load() or clearWarnings() is called.

Returns:
The warnings generated by the connection, statement, and result set, or null if none.
 o load
 public void load()
Loads the table based on the state of the system. This causes the query to be run. The query and connection properties must be set before this method is called. The table heading is reconstructed to ensure it matches the data, so any column customization will be lost.

 o refreshHeadings
 public void refreshHeadings()
Updates the table header to match the result set data. Any column customization will be lost.

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

Parameters:
listener - The listener.
 o removeListSelectionListener
 public void removeListSelectionListener(ListSelectionListener listener)
Removes a listener from being notified when the selection changes.

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.
Overrides:
removePropertyChangeListener in class JComponent
 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.
Overrides:
removeVetoableChangeListener in class JComponent
 o setColumnTitle
 public void setColumnTitle(int columnIndex,
                            String title)
Sets the title of a column. This is used for the table column heading.

Parameters:
columnIndex - The index of column. Indices start at 0.
title - The title for the column.
 o setColumnWidth
 public void setColumnWidth(int columnIndex,
                            int width)
Sets the width of a column.

Parameters:
columnIndex - The index of column. Indices start at 0.
width - The column width.
 o setConnection
 public void setConnection(SQLConnection connection) throws PropertyVetoException
Sets the SQL connection with which to access data. This property is bound and constrained. Note that the data in the table will not change until a load() is done.

Parameters:
connection - The SQL connection.
Throws: PropertyVetoException
If the change is vetoed.
 o setGridColor
 public void setGridColor(Color color)
Sets the color used to draw grid lines.

Parameters:
color - The color used to draw the grid lines.
 o setQuery
 public void setQuery(String query) throws PropertyVetoException
Sets the SQL query used to build the table. This property is bound and constrained. Note that the data in the table will not change until a load() is done.

Parameters:
query - The SQL query.
Throws: PropertyVetoException
If the change is vetoed.
 o setSelectionModel
 public void setSelectionModel(ListSelectionModel model)
Sets the ListSelectionModel that is used to maintain row selection state.

Parameters:
model - The model that provides the row selection state.
 o setShowHorizontalLines
 public void setShowHorizontalLines(boolean show)
Sets whether horizontal lines are drawn between rows.

Parameters:
show - true if horizontal lines are to be drawn; false otherwise.
 o setShowVerticalLines
 public void setShowVerticalLines(boolean show)
Sets whether vertical lines are drawn between columns.

Parameters:
show - true if vertical lines are to be drawn; false otherwise.

All Packages  Class Hierarchy  This Package  Previous  Next  Index