com.ibm.as400.vaccess

Class SQLResultSetTablePane

  • java.lang.Object
    • java.awt.Component
      • java.awt.Container
        • javax.swing.JComponent
          • com.ibm.as400.vaccess.SQLResultSetTablePane
  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

    Deprecated. 
    Use Java Swing instead, along with the classes in package com.ibm.as400.access

    public class SQLResultSetTablePane
    extends javax.swing.JComponent
    implements java.io.Serializable
    The SQLResultSetTablePane class represents a graphical user interface that presents the contents of a JDBC result set generated by an SQL query in a JTable.

    You must specify an SQLConnection object and SQL query string to use for generating the data. Alternately, you can specify a ResultSet object directly. If you specify a ResultSet object, it will override any SQLConnection or SQL query previously set. In addition, if you specify a ResultSet, this class will use memory more efficiently if you create the ResultSet as scrollable.

    You must explicitly call load() to load the information from the result set. The table will be empty until load() is called. If the query or result set includes updatable columns, then the respective columns will be editable.

    This class assumes that the necessary JDBC driver(s) are already registered.

    Call close() to ensure that the result set is closed when this table is no longer needed.

    Most errors are reported as ErrorEvents rather than throwing exceptions. Listen for ErrorEvents in order to diagnose and recover from error conditions.

    SQLResultSetTablePane objects generate the following events:

    • ErrorEvent
    • PropertyChangeEvent
    • TableModelEvent
    • WorkingEvent

    This example creates an SQLResultSetTablePane using an SQLConnection and query and displays it using a JTable:

    // Register the IBM Toolbox for Java JDBC driver.
    DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
    
    // Create the SQLResultSetTablePane object. SQLConnection connection = new SQLConnection("jdbc:as400://MySystem", "Userid", "Password"); String query = "SELECT * FROM MYLIB.MYTABLE"; SQLResultSetTablePane table = new SQLResultSetTablePane(connection, query);
    // Put the table in a JFrame. JFrame frame = new JFrame("My Window"); frame.getContentPane().add(table);
    // Set up the error dialog adapter. table.addErrorListener(new ErrorDialogAdapter(frame));
    // Display the JFrame. frame.pack(); frame.show();
    // Load the contents of the table. table.load();

    This example creates an SQLResultSetTablePane using a ResultSet and displays it using a JTable:

    // Register the IBM Toolbox for Java JDBC driver.
    DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
    
    // Use JDBC to execute the SQL query directly. Connection connection = DriverManager.getConnection("jdbc:as400://MySystem", "Userid", "Password"); Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = statement.executeQuery("SELECT * FROM MYLIB.MYTABLE");
    // Create the SQLResultSetTablePane object. SQLResultSetTablePane table = new SQLResultSetTablePane(rs);
    // Put the table in a JFrame. JFrame frame = new JFrame("My Window"); frame.getContentPane().add(table);
    // Set up the error dialog adapter. table.addErrorListener(new ErrorDialogAdapter(frame));
    // Display the JFrame. frame.pack(); frame.show();
    // Load the contents of the table. table.load();
    See Also:
    Serialized Form
  • >
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      • 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 Summary

      Constructors 
      Constructor and Description
      SQLResultSetTablePane()
      Deprecated. 
      Constructs a SQLResultSetTablePane object.
      SQLResultSetTablePane(java.sql.ResultSet resultSet, boolean cacheAll)
      Deprecated. 
      Constructs a SQLResultSetTablePane object.
      SQLResultSetTablePane(SQLConnection connection, java.lang.String query)
      Deprecated. 
      Constructs a SQLResultSetTablePane object.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addErrorListener(ErrorListener listener)
      Deprecated. 
      Adds a listener to be notified when an error occurs.
      void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
      Deprecated. 
      Adds a listener to be notified when the selection changes.
      void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
      Deprecated. 
      Adds a listener to be notified when the value of any bound property is changed.
      void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Deprecated. 
      Adds a listener to be notified when the value of any constrained property is changed.
      void clearWarnings()
      Deprecated. 
      Clears all SQL warnings.
      void close()
      Deprecated. 
      Closes the SQL result set this table represents.
      javax.swing.table.TableColumnModel getColumnModel()
      Deprecated. 
      Returns the column model for this table.
      java.lang.String getColumnTitle(int columnIndex)
      Deprecated. 
      Returns the title of a column.
      int getColumnWidth(int columnIndex)
      Deprecated. 
      Returns the width of a column.
      SQLConnection getConnection()
      Deprecated. 
      Returns the SQL connection with which to access data.
      SQLResultSetTableModel getDataModel()
      Deprecated. 
      Returns the data model for the table.
      java.awt.Color getGridColor()
      Deprecated. 
      Returns the color used to draw grid lines.
      java.lang.String getQuery()
      Deprecated. 
      Returns the SQL query used to generate the table data.
      java.sql.ResultSet getResultSet()
      Deprecated. 
      Returns the SQL result set.
      javax.swing.ListSelectionModel getSelectionModel()
      Deprecated. 
      Returns the ListSelectionModel that is used to maintain row selection state.
      boolean getShowHorizontalLines()
      Deprecated. 
      Returns whether horizontal lines are drawn between rows.
      boolean getShowVerticalLines()
      Deprecated. 
      Returns whether vertical lines are drawn between columns.
      java.lang.String getStringValueAt(int rowIndex, int columnIndex)
      Deprecated. 
      Returns the string value at the specifed row and column.
      java.lang.Object getValueAt(int rowIndex, int columnIndex)
      Deprecated. 
      Returns the value at the specifed row and column.
      java.sql.SQLWarning getWarnings()
      Deprecated. 
      Returns the warnings generated by the JDBC connection, statement, and result set.
      void load()
      Deprecated. 
      Loads the table based on the state of the system.
      static void main(java.lang.String[] args)
      Deprecated. 
       
      void refreshHeadings()
      Deprecated. 
      Updates the table header to match the result set data.
      void removeErrorListener(ErrorListener listener)
      Deprecated. 
      Removes a listener from being notified when an error occurs.
      void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
      Deprecated. 
      Removes a listener from being notified when the selection changes.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      Deprecated. 
      Removes a listener from being notified when the value of any bound property is changed.
      void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
      Deprecated. 
      Removes a listener from being notified when the value of any constrained property is changed.
      void setColumnTitle(int columnIndex, java.lang.String title)
      Deprecated. 
      Sets the title of a column.
      void setColumnWidth(int columnIndex, int width)
      Deprecated. 
      Sets the width of a column.
      void setConnection(SQLConnection connection)
      Deprecated. 
      Sets the SQL connection with which to access data.
      void setGridColor(java.awt.Color color)
      Deprecated. 
      Sets the color used to draw grid lines.
      void setQuery(java.lang.String query)
      Deprecated. 
      Sets the SQL query used to build the table.
      void setResultSet(java.sql.ResultSet resultSet)
      Deprecated. 
      Sets the SQL result set used to build the table.
      void setSelectionModel(javax.swing.ListSelectionModel model)
      Deprecated. 
      Sets the ListSelectionModel that is used to maintain row selection state.
      void setShowHorizontalLines(boolean show)
      Deprecated. 
      Sets whether horizontal lines are drawn between rows.
      void setShowVerticalLines(boolean show)
      Deprecated. 
      Sets whether vertical lines are drawn between columns.
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SQLResultSetTablePane

        public SQLResultSetTablePane()
        Deprecated. 
        Constructs a SQLResultSetTablePane object.
      • SQLResultSetTablePane

        public SQLResultSetTablePane(SQLConnection connection,
                             java.lang.String query)
        Deprecated. 
        Constructs a SQLResultSetTablePane object.
        Parameters:
        connection - The SQL connection.
        query - The SQL query.
      • SQLResultSetTablePane

        public SQLResultSetTablePane(java.sql.ResultSet resultSet,
                             boolean cacheAll)
        Deprecated. 
        Constructs a SQLResultSetTablePane object.
        Parameters:
        resultSet - The SQL result set.
        cacheAll - true to cache the entire result set when load() is called, false to cache parts of the result set as they are needed. Passing true may result in slow initial presentation of the data. However, it may be necessary to pass true if the result set is expected to close when the model is still needed.
    >
    • Method Detail

      • addErrorListener

        public void addErrorListener(ErrorListener listener)
        Deprecated. 
        Adds a listener to be notified when an error occurs.
        Parameters:
        listener - The listener.
      • addListSelectionListener

        public void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
        Deprecated. 
        Adds a listener to be notified when the selection changes.
        Parameters:
        listener - The listener.
      • addPropertyChangeListener

        public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
        Deprecated. 
        Adds a listener to be notified when the value of any bound property is changed.
        Overrides:
        addPropertyChangeListener in class java.awt.Container
        Parameters:
        listener - The listener.
      • addVetoableChangeListener

        public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Deprecated. 
        Adds a listener to be notified when the value of any constrained property is changed.
        Overrides:
        addVetoableChangeListener in class javax.swing.JComponent
        Parameters:
        listener - The listener.
      • clearWarnings

        public void clearWarnings()
        Deprecated. 
        Clears all SQL warnings.
      • close

        public void close()
        Deprecated. 
        Closes the SQL result set this table represents.
      • getColumnModel

        public javax.swing.table.TableColumnModel getColumnModel()
        Deprecated. 
        Returns the column model for this table.
        Returns:
        Model for this table's columns.
      • getColumnTitle

        public java.lang.String getColumnTitle(int columnIndex)
        Deprecated. 
        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.
      • getColumnWidth

        public int getColumnWidth(int columnIndex)
        Deprecated. 
        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.
      • getConnection

        public SQLConnection getConnection()
        Deprecated. 
        Returns the SQL connection with which to access data.
        Returns:
        The SQL connection.
      • getDataModel

        public SQLResultSetTableModel getDataModel()
        Deprecated. 
        Returns the data model for the table.
        Returns:
        The data model for the table.
      • getGridColor

        public java.awt.Color getGridColor()
        Deprecated. 
        Returns the color used to draw grid lines.
        Returns:
        The color used to draw grid lines.
      • getQuery

        public java.lang.String getQuery()
        Deprecated. 
        Returns the SQL query used to generate the table data.
        Returns:
        The SQL query.
      • getResultSet

        public java.sql.ResultSet getResultSet()
        Deprecated. 
        Returns the SQL result set.
        Returns:
        The SQL result set.
      • getSelectionModel

        public javax.swing.ListSelectionModel getSelectionModel()
        Deprecated. 
        Returns the ListSelectionModel that is used to maintain row selection state.
        Returns:
        The model that provides row selection state.
      • getShowHorizontalLines

        public boolean getShowHorizontalLines()
        Deprecated. 
        Returns whether horizontal lines are drawn between rows.
        Returns:
        true if horizontal lines are to be drawn; false otherwise.
      • getShowVerticalLines

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

        public java.lang.String getStringValueAt(int rowIndex,
                                        int columnIndex)
        Deprecated. 
        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.
      • getValueAt

        public java.lang.Object getValueAt(int rowIndex,
                                  int columnIndex)
        Deprecated. 
        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.
      • getWarnings

        public java.sql.SQLWarning getWarnings()
        Deprecated. 
        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.
      • load

        public void load()
        Deprecated. 
        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.
      • refreshHeadings

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

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

        public void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
        Deprecated. 
        Removes a listener from being notified when the selection changes.
        Parameters:
        listener - The listener.
      • removePropertyChangeListener

        public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
        Deprecated. 
        Removes a listener from being notified when the value of any bound property is changed.
        Overrides:
        removePropertyChangeListener in class java.awt.Component
        Parameters:
        listener - The listener.
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
        Deprecated. 
        Removes a listener from being notified when the value of any constrained property is changed.
        Overrides:
        removeVetoableChangeListener in class javax.swing.JComponent
        Parameters:
        listener - The listener.
      • setColumnTitle

        public void setColumnTitle(int columnIndex,
                          java.lang.String title)
        Deprecated. 
        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.
      • setColumnWidth

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

        public void setConnection(SQLConnection connection)
                           throws java.beans.PropertyVetoException
        Deprecated. 
        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:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setGridColor

        public void setGridColor(java.awt.Color color)
        Deprecated. 
        Sets the color used to draw grid lines.
        Parameters:
        color - The color used to draw the grid lines.
      • setQuery

        public void setQuery(java.lang.String query)
                      throws java.beans.PropertyVetoException
        Deprecated. 
        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:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setResultSet

        public void setResultSet(java.sql.ResultSet resultSet)
        Deprecated. 
        Sets the SQL result set used to build the table. If this is set, it is used instead of the SQL connection and SQL query. Note that the data in the table will not change until a load() is done.
        Parameters:
        resultSet - The SQL result set.
      • setSelectionModel

        public void setSelectionModel(javax.swing.ListSelectionModel model)
        Deprecated. 
        Sets the ListSelectionModel that is used to maintain row selection state.
        Parameters:
        model - The model that provides the row selection state.
      • setShowHorizontalLines

        public void setShowHorizontalLines(boolean show)
        Deprecated. 
        Sets whether horizontal lines are drawn between rows.
        Parameters:
        show - true if horizontal lines are to be drawn; false otherwise.
      • setShowVerticalLines

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

        public static void main(java.lang.String[] args)
        Deprecated.