Illegal ResultSet

OiRc

I got this error:java.sql.SQLException: Illegal operation on empty result set.I don't understand why, i loop in eventually searched rows with the while.

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);
                }
                }
Axel Amthor

Within the loop you're using rs instead of rs1. If this is not issuing a compiler error, I assume rs is in the global namespace but empty in the current state.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related