Holger's
Java API

com.antelmann.sql
Class JDBCTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.antelmann.sql.JDBCTableModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
JDBCRowModel

public class JDBCTableModel
extends AbstractTableModel

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

Since:
10/24/2002
Author:
Holger Antelmann
See Also:
ResultSetTableModel, JDBCRowModel, JTable, ConnectionHelper, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
JDBCTableModel(Connection con, String tableName)
           
JDBCTableModel(Connection con, String tableName, boolean updateable)
           
JDBCTableModel(Connection con, String tableName, String[] columnNames)
           
JDBCTableModel(Connection con, String tableName, String[] columnNames, boolean updateable)
           
 
Method Summary
 void close()
          closes the embedded statement used
protected  void finalize()
           
 int getColumnCount()
           
 String getColumnName(int column)
           
 Connection getConnection()
           
 Component getParentComponent()
           
 ResultSet getResultSet()
           
 int getRowCount()
           
 String getTableName()
           
 Object getValueAt(int row, int column)
           
 boolean isCellEditable(int row, int column)
           
 boolean isEditable()
           
 boolean isInsertMode()
           
 void refresh()
           
 void setColumnNames(String[] columnNames)
          the values must correspond to actual column names of the underlying table; setting null means to simply use all existing column names (the default).
 void setEditable(boolean flag)
           
 void setInsertMode(boolean flag)
           
 void setParentComponent(Component parent)
           
 void setValueAt(Object value, int row, int column)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, 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(Connection con,
                      String tableName)
               throws SQLException
Throws:
SQLException

JDBCTableModel

public JDBCTableModel(Connection con,
                      String tableName,
                      boolean updateable)
               throws SQLException
Throws:
SQLException

JDBCTableModel

public JDBCTableModel(Connection con,
                      String tableName,
                      String[] columnNames)
               throws SQLException
Throws:
SQLException

JDBCTableModel

public JDBCTableModel(Connection con,
                      String tableName,
                      String[] columnNames,
                      boolean updateable)
               throws SQLException
Throws:
SQLException
Method Detail

getConnection

public Connection getConnection()

getTableName

public String getTableName()

setColumnNames

public void setColumnNames(String[] columnNames)
the values must correspond to actual column names of the underlying table; setting null means to simply use all existing column names (the default). When the array is set to a non-null value, no error is thrown on this method call, but if the column names are incorrect, various exceptions may be thrown later on use of this model.


refresh

public void refresh()
             throws SQLException
Throws:
SQLException

getResultSet

public ResultSet getResultSet()

isEditable

public boolean isEditable()

setEditable

public void setEditable(boolean flag)

isInsertMode

public boolean isInsertMode()

setInsertMode

public void setInsertMode(boolean flag)

setParentComponent

public void setParentComponent(Component parent)

getParentComponent

public Component getParentComponent()

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getValueAt

public Object getValueAt(int row,
                         int column)

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

close

public void close()
           throws SQLException
closes the embedded statement used

Throws:
SQLException

finalize

protected void finalize()
                 throws Exception
Overrides:
finalize in class Object
Throws:
Exception


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads