首页 > 解决方案 > 我的数据库没有更新列上的条目

问题描述

我在 java swing 的 ATM 模拟器上做了一个程序,想更新我的余额,问题是在提交我想要更新的金额后,java 程序正在成功执行,没有任何错误,但更新没有显示在数据库中。我正在使用 pgadmin4。

private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
    // TODO add your handling code here:
     Connection con = null;
    PreparedStatement pst = null;
    MainAtm matm = new MainAtm();
    matm.fun();

    String sql = "UPDATE public.project SET balance=? WHERE card_no = ? AND pin = ? ;";

    try {
        con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "123");
        pst = con.prepareStatement(sql);
        pst.setInt(1, Integer.parseInt(depositTextField.getText()));
        pst.setString(2, matm.carad);
        pst.setString(3, matm.pen);
          pst.executeUpdate();
          JOptionPane.showMessageDialog(this, "Balance UPdated Successfully");
    } catch (SQLException ex) {
        Logger.getLogger(Deposit.class.getName()).log(Level.SEVERE, null, ex);
         JOptionPane.showMessageDialog(this, "Balance UPdated Successfully nhi hua");
    }
}

标签: javadatabasepostgresqlswingpgadmin-4

解决方案


推荐阅读