ResultSet rs;
rs = this.orderedProduct.select(" sum(unitstoproduce) "," soNo = "+ soNo);
int sum = Integer.parseInt(rs.getString(1));
当我尝试在java类中执行上述查询时,出现如下异常.
这是orderedProduct(orderedZnAlProduct)的表格
SELECT sum(unitstoproduce) FROM orderedZnAlProduct WHERE soNo = '15005'
java.sql.SQLException: Before start of result set
解决方法:
我看不到查询的执行位置(例如statement.executeQuery()),但是,当光标定位不正确时,通常会发生这种错误.您需要调用likers.next()或rs.first()来移动光标,然后获取结果.