首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >非法ResultSet

非法ResultSet
EN

Stack Overflow用户
提问于 2014-01-25 11:46:51
回答 1查看 49关注 0票数 0

我得到了一个错误:java.sql.SQLException: Illegal operation on empty result set.--我不明白为什么--我最终用时间循环搜索行。

代码语言:javascript
复制
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);
                }
                }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-25 12:00:31

在循环中,您使用的是rs而不是rs1。如果这没有发出编译器错误,我假设rs在全局命名空间中,但在当前状态下为空。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21350109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档