|Product:||JDBC DBConnectivity Product for IBM Db2 (HiT JDBC/DB2)|
|Summary:||Explanation for the error "[FETCH] result set is closed”|
The following exception can occur while processing a result set:
"[FETCH] result set is closed (possibly because another statement was committed"
This usually happens when you are processing multiple statements and one statement closes while the other is fetching a result set from the database. By default, autocommit is enabled and when a statement is closed: a commit is executed. Also by default, when a commit is executed in one statement, the cursor or result set being processed by other statements are also committed and closed. However, we can instruct the database not to commit, that is to "hold", all existing cursors or result sets when a commit is executed by setting the "hold_cursor" connection option to "yes". For example:
url = "jdbc:db2://mydb;rdbname=S390F50;package_collection_id=ABC;hold_cursor=yes";
If you process your SQL statements sequentially, you can also simply make sure that a statement is closed before creating a new one.