`

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事务,在对结果集进行操作就会报上面的错误。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics