我得到了这个错误:java.sql.SQLException: Illegal operation on empty result set.
我不明白为什么,我循环搜索最终搜索到的行。非法结果集
rs1=st1.executeQuery("select product.price,product.id from product,warehouse,shop
where product.brand ='"
+ Brand
+ "' and product.productType='"
+ Product
+ "'and shop.quantity + warehouse.quantity='"
+ Quantity
+ "' and product.id=shop.idProduct");
while (rs1.next()) {
price = rs.getInt("price");
idProduct = rs.getString("id");
countWareHouse++;
}
if (countWareHouse > 0) {
JOptionPane.showConfirmDialog(Sale,
"Do you want to add this " + Product
+ "int the cart?", "CART",
JOptionPane.OK_CANCEL_OPTION);
Prices.add(price);
}
}
你能显示完整的代码吗? –
你没有向我们展示这是罪魁祸首的代码。 “while”循环中有什么。并使用'PreparedStatement'来构建查询。 –
“品牌”,“产品”和“数量”应该是避免SQL注入攻击的参数。 – dasblinkenlight