Class ResultSetTableModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.table.TableModel

    public class ResultSetTableModel
    extends javax.swing.table.AbstractTableModel
    An implementation of a javax.swing.table.TableModel that updates itself from a scrollable java.sql.ResultSet source. This directly maps columns from a query to columns in the table model. If you wish to filter information from the result set before it is output as a table use FilteredResultSetTableModel.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.sql.ResultSetMetaData meta_data
      The ResultSetMetaData object for this result set.
      private boolean preserve_table_structure
      If true, a table structure change event is NOT thrown if the result set looks similar to an updated result set.
      private java.sql.ResultSet result_set
      The scrollable ResultSet source.
      private int row_count
      The number of rows in the result set.
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears the model of the current result set.
      int getColumnCount()  
      java.lang.String getColumnName​(int column)  
      int getRowCount()  
      java.lang.Object getValueAt​(int row, int column)  
      void setPreserveTableStructure​(boolean status)
      A property that checks for changes when a result set is updated and preserves the layout if the updated result set looks similar.
      void updateResultSet​(java.sql.ResultSet result_set)
      Updates the result set in this model with the given ResultSet object.
      • Methods inherited from class javax.swing.table.AbstractTableModel

        addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • result_set

        private java.sql.ResultSet result_set
        The scrollable ResultSet source.
      • meta_data

        private java.sql.ResultSetMetaData meta_data
        The ResultSetMetaData object for this result set.
      • row_count

        private int row_count
        The number of rows in the result set.
      • preserve_table_structure

        private boolean preserve_table_structure
        If true, a table structure change event is NOT thrown if the result set looks similar to an updated result set.
    • Constructor Detail

      • ResultSetTableModel

        public ResultSetTableModel​(java.sql.ResultSet result_set)
        Constructs the model.
      • ResultSetTableModel

        public ResultSetTableModel()
    • Method Detail

      • setPreserveTableStructure

        public void setPreserveTableStructure​(boolean status)
        A property that checks for changes when a result set is updated and preserves the layout if the updated result set looks similar. This means that the width of columns in the UI will not change to their default values.
      • updateResultSet

        public void updateResultSet​(java.sql.ResultSet result_set)
        Updates the result set in this model with the given ResultSet object.
      • clear

        public void clear()
        Clears the model of the current result set.
      • getRowCount

        public int getRowCount()
      • getColumnCount

        public int getColumnCount()
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)