我得到了一个错误: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);
}
}发布于 2014-01-25 12:00:31
在循环中,您使用的是rs而不是rs1。如果这没有发出编译器错误,我假设rs在全局命名空间中,但在当前状态下为空。
https://stackoverflow.com/questions/21350109
复制相似问题