SQLException:在结果集开始之前 [英] SQLException : Before start of result set

查看:179
本文介绍了SQLException:在结果集开始之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   ResultSet rs;
   rs = this.orderedProduct.select(" sum(unitstoproduce) "," soNo = "+ soNo);

   int sum = Integer.parseInt(rs.getString(1));

当我尝试在java类中执行上述查询时,我得到一个异常如下。
这里orderedProduct(orderedZnAlProduct)是表

When i try to execute the above query inside the java class i'm getting an exception as below. Here the orderedProduct(orderedZnAlProduct) is the table

   SELECT  sum(unitstoproduce)  FROM orderedZnAlProduct WHERE  soNo = '15005'

   java.sql.SQLException: Before start of result set


推荐答案

我没有看到您的查询执行的位置(如statement.executeQuery())但是,当光标位置不正确时,通常会发生这种错误。您需要调用类似 rs.next() rs.first()的内容来移动光标然后再移动到得到结果。

I don't see where your query is executed (like statement.executeQuery()) but, this kind of errors generally happens when your cursor is not well positioned. You need to call something likers.next() or rs.first() to move your cursor and then to get the result.

这篇关于SQLException:在结果集开始之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆