我得到了這個錯誤: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