0

我使用 Dbutils 调用一个数据库表中的元素

private void showEvent(){

    try {
        String query="SELECT EventID, MemberID,Description, Date, 
        Time, Venue, EventTypes  FROM formal UNION SELECT EventID, 
        MemberID,Description, Date, Time, Venue, EventTypes FROM social";

        ps = c.prepareStatement(query);

        rs=ps.executeQuery();

        tbShowEvent.setModel(DbUtils.resultSetToTableModel(rs));

    } catch (SQLException ex) {
        Logger.getLogger(ShowEvent.class.getName()).log(Level.SEVERE, null, ex);
    }
}

当我将鼠标单击到该元素时如何删除表格中的一个元素

在此处输入图像描述 插图:http: //i.stack.imgur.com/ib77V.png

4

1 回答 1

0
  • add an event listener on your delete button
  • create your stored procedure code for the delete in the event listener.
  • after a succesful delete in the DB delete the row in your table in the table Model
  • refresh you table. Call fireTableDataChanged() on your tableModel
于 2014-01-13T07:11:52.910 回答