gpt4 book ai didi

java - DB2 错误 SQLCODE=-103,SQLSTATE=42604

转载 作者:行者123 更新时间:2023-12-01 23:54:15 29 4
gpt4 key购买 nike

我正在尝试更新表,但它不起作用并给出此 sql 错误。

//Updating Buy Table
Integer stkbid = Integer.parseInt(request.getParameter("stockBid"));
System.out.println("stock buy id : " + stkbid);
//get buy details
PreparedStatement stmtbuy = conn.prepareStatement(
"SELECT \"StockSymbol\", \"Unit\", \"Price\", \"ClearingFee\", \"StampDuty\", \"BrokerFee\"" +
"FROM SPM.\"StockBuy\" WHERE \"StockBuyId\" = '"+ stkbid + "'");

System.out.println("Got stock buy details");

ResultSet rs=stmtbuy.executeQuery();
rs.next();
//String stkcode = rs.getString("StockSymbol");
Integer stkunit = Integer.parseInt(rs.getString("Unit"));
stkunit -= stock.getStockUnit();
Double stkprice = Double.parseDouble(rs.getString("Price"));
Double stkclear = Double.parseDouble(rs.getString("ClearingFee"));
Double stksd = Double.parseDouble(rs.getString("StampDuty"));
Double stkbfee = Double.parseDouble(rs.getString("BrokerFee"));
Double stkval = stkunit * stkprice;
Double stknv = stkval + stkval * (stkclear + stksd + stkbfee);

System.out.println(stknv);

PreparedStatement stmtbuy1 = conn.prepareStatement(
"UPDATE SPM.\"StockBuy\" SET \"Unit\" = " + stkunit + ", \"Value\" = " + stkval + ", \"NetValue\" = " + stknv +
"WHERE \"StockBuyId\" = "+ stkbid);

最佳答案

您在 WHERE 子句之前缺少一个空格,这弄乱了您的 stknv

" WHERE \"StockBuyId\" = "+ stkbid);

我认为任何发帖人都有义务提醒您应该使用参数化查询。所以我也会这样做。

请使用参数化查询!

关于java - DB2 错误 SQLCODE=-103,SQLSTATE=42604,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15851921/

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