java.sql.SQLException: ResultSet not open, operation 'next' not permitted.

java.sql.SQLException: ResultSet not open, operation 'next' not permitted. Verify that autocommit is OFF。
错误翻译:结果集没有打开,next操作不允许。请确认自动提交是否关闭。

最近碰到这个错误弄的很郁闷。查看程序获取连接后明明把autocommit给关闭了,还是报这样错误让人感觉火冒三丈。最终功夫不负有心人,在英文网站找到了解决办法:
Frequently asked questions

Question
I am currently using Cloudscape� 3.5. I have multiple connections, all with autocommit set to false.

I sometimes get this exception after executing a prepared Select-statement and calling the next() method of the ResultSet:

SQL Exception: ResultSet not open, operation next not permitted.
Verify that autocommit is OFF.

As autocommit is turned off for all connections the message is not helpful. Could you explain what this means and how to avoid it?

I had an issue some time ago with multiple connections. It looked as if one connection was blocked by another, although both were only reading some tables. The exception said that 'A lock could not be obtained within the time requested.' I resolved this by committing often, even after reading some tables. Maybe the current issue is related to this?

原因分析:参考上面说的建议以及实现环境,发现程序循环处理结果集,完成400条处理以后就手工提交一次事务,结果就在提交后又取结果集时报上面的错误。
解决办法:就是循环处理结果集,处理完了一次性提交。这种错误一般在所内有限的数据(也就是结果集数据少于400)不会报的,比较隐蔽。

获取一个数据库连接,通过查询获取结果集,对结果集进行操作,如果这时commit事务,在对结果集进行操作就会报上面的错误。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值