gpt4 book ai didi

java - 如何更改已满足值的表中的值?

转载 作者:行者123 更新时间:2023-12-01 16:22:22 25 4
gpt4 key购买 nike

我有一个表,其中有 13 列。我需要将这 13 列中的先前值替换为第 11 行中的更新值。

if (Integer.parseInt(res.getString("res_id")) == res_id) {
if (Integer.parseInt(res.getString("rem_pay")) > 0) {
String a = res.getString("rem_pay");
System.out.println("You need to pay the remaining amount: " + a);
System.out.println("How much you want to pay?");
amount=scanner.nextDouble();
String query1= "INSERT INTO reservations values()"; //Changing the old rem_pay with the new one which the variable amount
amount=Double.parseDouble(res.getString("rem_pay"))-amount;

任何答案都会非常有帮助。

最佳答案

像这样更新表格:

amount = Double.parseDouble(res.getString("rem_pay"))-amount;
String query1 = "UPDATE reservations SET amount=?";
PreparedStatement pstm = connection.prepareStatement(query1);
pStatement.setDouble(1, amount);
pstm.executeUpdate();

关于java - 如何更改已满足值的表中的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62234289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com