我在程序中实现AbstractTableModel中的setValueAt方法,将对table中的修改提交到数据库中出现了如下错误:
java.lang.ClassCastException: java.lang.Integer
at MyTableModel.setValueAt(MyTableModel.java:82)
方法如下:
public void setValueAt(Object value,int row,int col){
   Integer newValue;
   Vector currentRow=(Vector)rowData.get(row);
   try{
   newValue=Integer.valueOf((String)value); //这是第82行
   }
   catch(NumberFormatException e1){
   newValue=new Integer(0);
   }
   String id=(String)currentRow.get(0);
   String columnName=col==2?"MIDEXAM":"FINALEXAM";
   try{
   stmt.executeUpdate("update student set "+columnName+"="+newValue+"   where ID='"+id+"'");
   currentRow.set(col,newValue);
   float average=(((Integer)currentRow.get(2)).intValue()+((Integer)currentRow.get(3)).intValue())/(float)2.0;
   currentRow.set(4,new Float(average));
   fireTableCellUpdated(row,4);
   }
   catch(SQLException e2){
   System.out.println(e2);
   }
   
   }