我已经通过使用TableModelListener直接键入Jtable单元格来为数据库设置了值。但是更新后我无法在Jtable中重新加载数据。

public void setValueAt(Object value, int row, int column) {
    String updateq = "update M_department set " + getColumnName(column) + "='"
            + value.toString() + "' where code='" + getValueAt(row, 0) + "'";
    System.out.println(updateq);
    try {
        stmt.executeUpdate(updateq);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.out.println("Error" + e);
    }
}

最佳答案

您应该调用super.GetValueAt()。如果要从数据库重新加载数据,则必须重新初始化模型,这很大程度上取决于实现模型的方式。

09-04 09:33
查看更多