Java删除数据库更新面板

时间:2015-02-20 03:11:56

标签: java database

每次我从我的JButton中删除一些东西,它会在数据库中删除,但我的jpanel不会更新... 我想知道是否有一个简单的解决方法吗?

private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {                                       
    infLabel.setText(inform[2]);

    Connection connection = FlatFinder.getConnection();
    Statement selectStmt = null;
    try {
        selectStmt = connection.createStatement();
        Flat activeFlat = (Flat) AdminAll.getSelectedValue();
        String sql = String.format(
                "DELETE FROM `flats` WHERE flat_id = %d",
                activeFlat.getId()
        );
        selectStmt.executeUpdate(sql);
    } catch (SQLException ex) {
        Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    this.repaint();
}     

这是我目前的代码。当我按下删除按钮时,是否有任何简单的解决方案来更新jpanel?

0 个答案:

没有答案