Hi
Data cannot update in the table. when we click button once then data will show in the table, again we click the DefaultTablemodel can update but the data cannot update in the table. please help me .
the code is below
class MyTableModel extends AbstractTableModel {
/**
*
*/
private static final long serialVersionUID = 3557014627615565384L;
//Declare the String
final String[] column_Names = { "ID", "TOTAL SESSION", "AVAILABLE" };
private ArrayList<Object> data = new ArrayList<Object>();
private String uname = "", pword = "", url = "", schema = "";
private Propertyread Propertyfile;
private String Query;
public TableModel abtmodel = null;
Connection conn = null;
Statement stmt = null;
MyTableModel(ResultSet rs)throws SQLException {
// Call the perpertyread class's method is findPropertyfile()
while (rs.next()) {
data.add(rs.getInt("memid"));
data.add(rs.getInt("totalsession"));
data.add(rs.getInt("available"));
}
fireTableDataChanged();
Object[][] Objdata={{data.toArray()}};
abtmodel = new DefaultTableModel(Objdata, column_Names);
System.out.println("abstract 1 "+data);
}
public int getColumnCount() {
// TODO Auto-generated method stub
return column_Names.length;
}
public int getRowCount() {
// TODO Auto-generated method stub
return 1;
}
public Object getValueAt(int rowIndex, int columnIndex) {
// TODO Auto-generated method stub
return data.get(columnIndex);
}
public String getColumnName(int c) {
return column_Names[c];
}
public boolean isCellEditable(int row, int col) {
return false;
}
public void setValueAt(Object value, int row, int col) {
data.set(row, value);
this.fireTableDataChanged();
System.out.println("New data Updated");
}
public void addRow(ArrayList row){
data.add(row);
this.fireTableDataChanged();
}
public void delRow(int row) {
data.remove(row);
this.fireTableDataChanged();
System.out.println("delete");
}
public void addResultSet(ResultSet rs)throws SQLException{
// data.clear();
while (rs.next()) {
data.add(rs.getInt("memid"));
data.add(rs.getInt("totalsession"));
data.add(rs.getInt("available"));
}
fireTableDataChanged();
Object[][] Objdata={{data.toArray()}};
abtmodel = new DefaultTableModel(Objdata, column_Names);
System.out.println("abstract 2 "+data);
this.fireTableDataChanged();
}
}