java - 我的数据库没有更新列上的条目
问题描述
我在 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");
}
}
解决方案
推荐阅读
- laravel - Laravel SVG 文件验证不接受 svg 文件
- maven - 需要在我的 selenium 黄瓜项目中使用 serenity bdd 生成报告
- java-8 - 多个@EnsuresNonNullIf 应该没问题;但编译器抱怨
- javascript - 为什么 Jest 快照会因为双引号而包含转义字符?
- sql-server - “将表达式转换为数据类型 nvarchar 的算术溢出错误”:pypyodbc + SQL Server
- ruby - 找不到结束输入丢失的位置
- django - 有没有办法让鹡鸰身体字段只读?
- android - 从 Android 应用程序访问 i.mx6 板上的 I2C
- javascript - 一个人如何使用不和谐机器人将频道添加到某个类别?
- jquery - 通过 JQuery 使用 SlideDown 和 SlideUp 更改图标