/** */ /** * Create on Feb 7, 2007 */ package com.jinfonet.loganalyzer.ui.viewers; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import javax.swing.table.AbstractTableModel; /** */ /** * @author gengwei.zheng * */ public abstract class DataTableModel extends AbstractTableModel ... { private ResultSet rs; private ResultSetMetaData rsmd; public DataTableModel(ResultSet aResultSet) ...{ this.rs = aResultSet; try ...{ rsmd = rs.getMetaData(); } catch (SQLException e) ...{ e.printStackTrace(); } } public String getColumnName(int column) ...{ if (column == 0) ...{ return ""; } else ...{ try ...{ return rsmd.getColumnName(column); } catch (SQLException e) ...{ e.printStackTrace(); return ""; } } } public int getColumnCount() ...{ try ...{ return rsmd.getColumnCount() + 1; } catch (SQLException e) ...{ e.printStackTrace(); return 0; } } public boolean isCellEditable(int row, int column) ...{ if (column == 0) return true; return false; } protected ResultSet getResultSet() ...{ return rs; } protected void refetchData(ResultSet rs) ...{ this.rs = rs; try ...{ rsmd = rs.getMetaData(); } catch (SQLException e) ...{ e.printStackTrace(); } }}