iglu.jdbc
Class SQLTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--iglu.jdbc.JDBCTableModel
              |
              +--iglu.jdbc.SQLTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class SQLTableModel
extends JDBCTableModel

A class to provide data to a table based on an sql select statement. This makes browsing a databse table in Java quite easy. What makes this more powerful than an ordinary TableModel is that you can specify what fields of the query to display on the table, but still retrieve the values of the other fields from the table model. See JDBCTableModel for more. The nifty thing about this is that you can change the contents of the table by running newQuery. Let's you change the contents of a table on-the-fly.

Version:
1.0
Author:
Travis Bauer trbauer@indiana.edu
See Also:
JDBCTableModel, Serialized Form

Field Summary
protected  java.sql.Connection sqlConnection
          The connection to the database
protected  java.lang.String sqlStatement
          the sql statement to print
 
Fields inherited from class iglu.jdbc.JDBCTableModel
bm, bookmark, colsToDisplay, numRows, rs
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SQLTableModel(java.sql.Connection sqlc)
          create an empty model, only specifying the connection.
SQLTableModel(java.lang.String sqls, java.sql.Connection sqlc)
          create a table model from the given sql statement display all collumns.
SQLTableModel(java.lang.String sqls, java.sql.Connection sqlc, int[] ncols)
          create a table model form the given sql statement, displaying the columns listed in ncols
 
Method Summary
protected  void executeSQL()
          re-execute the sql statement
 java.lang.String getSql()
          get the sql statement upon which this table is based
 void newQuery(java.lang.String nsql, boolean recalcCols)
          executes a new sql statement, assuming the same column count/ display information if recalcCols is false.
 void newQuery(java.lang.String nsql, int[] ncols)
          execute a new sql statement, letting the column information change
 void reQuery()
          re-execute the sql statement, and issue a fireTableChanged event
protected  void showAllCols()
          configure the object to show all the columns.
 
Methods inherited from class iglu.jdbc.JDBCTableModel
bookmark, figureNumRows, getBookmarkString, getColumnCount, getColumnName, getRowCount, getValueAt, rs, setBookmark, setColsToDisplay
 
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

sqlStatement

protected java.lang.String sqlStatement
the sql statement to print


sqlConnection

protected java.sql.Connection sqlConnection
The connection to the database

Constructor Detail

SQLTableModel

public SQLTableModel(java.sql.Connection sqlc)
create an empty model, only specifying the connection. Call newQuery to fill this model with information


SQLTableModel

public SQLTableModel(java.lang.String sqls,
                     java.sql.Connection sqlc)
create a table model from the given sql statement display all collumns.


SQLTableModel

public SQLTableModel(java.lang.String sqls,
                     java.sql.Connection sqlc,
                     int[] ncols)
create a table model form the given sql statement, displaying the columns listed in ncols

Method Detail

reQuery

public void reQuery()
re-execute the sql statement, and issue a fireTableChanged event


newQuery

public void newQuery(java.lang.String nsql,
                     boolean recalcCols)
executes a new sql statement, assuming the same column count/ display information if recalcCols is false. Otherwise show all columns


newQuery

public void newQuery(java.lang.String nsql,
                     int[] ncols)
execute a new sql statement, letting the column information change


executeSQL

protected void executeSQL()
re-execute the sql statement


showAllCols

protected void showAllCols()
configure the object to show all the columns. Assumes the query has already been called


getSql

public java.lang.String getSql()
get the sql statement upon which this table is based