sg.edu.nus.gui.server
Class DatabaseQueryTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by sg.edu.nus.gui.server.DatabaseQueryTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class DatabaseQueryTableModel
extends javax.swing.table.AbstractTableModel

This DatabaseQueryTableModel is a basic implementation of TableModel interface that fills out a Vector from a query's result set

Version:
August-6-2008
Author:
Han Xixian
See Also:
Serialized Form

Constructor Summary
DatabaseQueryTableModel()
           
 
Method Summary
 void closeDB()
          close the connection to specified database
 int getColumnCount()
           
 java.lang.String getColumnName(int i)
           
 java.lang.String getDatabaseName()
           
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int col)
           
 void initDB()
          Initialize Database to obtain the connection to specified database
 void setDatabaseName(java.lang.String databaseName)
           
 void setQuery(java.lang.String sql)
          setQuery is used to execute the specified query, and return the results
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseQueryTableModel

public DatabaseQueryTableModel()
Method Detail

getDatabaseName

public java.lang.String getDatabaseName()
Returns:
the databaseName

setDatabaseName

public void setDatabaseName(java.lang.String databaseName)
Parameters:
databaseName - the databaseName to set

initDB

public void initDB()
Initialize Database to obtain the connection to specified database


closeDB

public void closeDB()
close the connection to specified database


setQuery

public void setQuery(java.lang.String sql)
setQuery is used to execute the specified query, and return the results

Parameters:
sql -

getColumnCount

public int getColumnCount()

getRowCount

public int getRowCount()

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)

getColumnName

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

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel