org.jscience.util
Class JDBCTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.jscience.util.JDBCTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class JDBCTableModel
extends javax.swing.table.AbstractTableModel

JDBCTableModel provides a simple way to display a table from a JDBC connection. An additional feature is that this model is also editable.

Since:
10/24/2002
See Also:
JTable, JDBC, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
JDBCTableModel(java.sql.Connection con, java.lang.String tableName)
          Creates a new JDBCTableModel object.
JDBCTableModel(java.sql.Connection con, java.lang.String tableName, boolean updateable)
          Creates a new JDBCTableModel object.
 
Method Summary
 void close()
          DOCUMENT ME!
protected  void finalize()
          DOCUMENT ME!
 java.lang.Class getColumnClass(int column)
          DOCUMENT ME!
 int getColumnCount()
          DOCUMENT ME!
 java.lang.String getColumnName(int column)
          DOCUMENT ME!
 java.awt.Component getParentComponent()
          DOCUMENT ME!
 java.sql.ResultSet getResultSet()
          DOCUMENT ME!
 int getRowCount()
          DOCUMENT ME!
 java.sql.Statement getStatement()
          DOCUMENT ME!
 java.lang.Object getValueAt(int row, int column)
          DOCUMENT ME!
 boolean isCellEditable(int row, int column)
          DOCUMENT ME!
 boolean isEditable()
          DOCUMENT ME!
 void refresh()
          DOCUMENT ME!
 void setEditable(boolean flag)
          DOCUMENT ME!
 void setParentComponent(java.awt.Component parent)
          DOCUMENT ME!
 void setValueAt(java.lang.Object value, int row, int column)
          DOCUMENT ME!
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCTableModel

public JDBCTableModel(java.sql.Connection con,
                      java.lang.String tableName)
               throws java.sql.SQLException
Creates a new JDBCTableModel object.

Parameters:
con - DOCUMENT ME!
tableName - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!

JDBCTableModel

public JDBCTableModel(java.sql.Connection con,
                      java.lang.String tableName,
                      boolean updateable)
               throws java.sql.SQLException
Creates a new JDBCTableModel object.

Parameters:
con - DOCUMENT ME!
tableName - DOCUMENT ME!
updateable - DOCUMENT ME!
Throws:
java.sql.SQLException - DOCUMENT ME!
Method Detail

getResultSet

public java.sql.ResultSet getResultSet()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getStatement

public java.sql.Statement getStatement()
DOCUMENT ME!

Returns:
DOCUMENT ME!

refresh

public void refresh()
             throws java.sql.SQLException
DOCUMENT ME!

Throws:
java.sql.SQLException - DOCUMENT ME!

isEditable

public boolean isEditable()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setEditable

public void setEditable(boolean flag)
DOCUMENT ME!

Parameters:
flag - DOCUMENT ME!

setParentComponent

public void setParentComponent(java.awt.Component parent)
DOCUMENT ME!

Parameters:
parent - DOCUMENT ME!

getParentComponent

public java.awt.Component getParentComponent()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRowCount

public int getRowCount()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getColumnCount

public int getColumnCount()
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
java.lang.RuntimeException - DOCUMENT ME!

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
DOCUMENT ME!

Parameters:
row - DOCUMENT ME!
column - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.RuntimeException - DOCUMENT ME!

getColumnName

public java.lang.String getColumnName(int column)
DOCUMENT ME!

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
column - DOCUMENT ME!
Returns:
DOCUMENT ME!

getColumnClass

public java.lang.Class getColumnClass(int column)
DOCUMENT ME!

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
column - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.RuntimeException - DOCUMENT ME!

isCellEditable

public boolean isCellEditable(int row,
                              int column)
DOCUMENT ME!

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
row - DOCUMENT ME!
column - DOCUMENT ME!
Returns:
DOCUMENT ME!

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int column)
DOCUMENT ME!

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
value - DOCUMENT ME!
row - DOCUMENT ME!
column - DOCUMENT ME!
Throws:
java.lang.RuntimeException - DOCUMENT ME!

close

public void close()
           throws java.sql.SQLException
DOCUMENT ME!

Throws:
java.sql.SQLException - DOCUMENT ME!

finalize

protected void finalize()
                 throws java.lang.Exception
DOCUMENT ME!

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Exception - DOCUMENT ME!