Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
SQLException when using selectCursor on DB2 #1345
We are using the selectCursor method of SqlSession to stream a large result set from a DB2 database. On DB2 this operation always fails when trying to read the last object from the cursor's iterator specifically for select statements that use a result mapping with nested results.
After some investigation I have found that this error occurs because the DB2 driver behaves differently from most other databases. As soon as the
I had a look at the code and the exception occurs because the DefaultCursor calls the
Database vendor and version
IBM DB2 LUW version 9.7 (JDBC driver: db2jcc4_9.7fp11.jar)
Test case or example project
I cannot provide a working example project because the problem only occurs when run with a DB2 database. However, the existing integration tests in
Steps to reproduce
Execute a select query with "resultOrdered" set to "true" using a Mybatis cursor (either by using a Mapper interface returning a Cursor instance or by calling the selectCursor method of SqlSession) and where the result map contains one or more nested result maps. When run using the DB2 database driver this results in an exception when reading the last object from the iterator.
We should be able to read all objects from the Mybatis Cursor without receiving any exceptions.
When we try to consume the last object from the Cursor's iterator we receive the following exception:
Hi @ddoaj97 ,
Thank you for the detailed report. Your analysis looks perfect.
I should also mention that there is a workaround .
 There is a driver property