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()),但是,当光标位置不正确时,通常会发生这种错误。您需要调用类似rs.next()或rs.first()移动光标的方法,然后才能获得结果。
rs.next()
rs.first()