[ 
http://issues.apache.org/jira/browse/IBATIS-109?page=comments#action_12367021 ] 

Sven Boden commented on IBATIS-109:
-----------------------------------

I would like to implement the fix for JIRA IBATIS-109... checkin around 
February 24 unless someone has objections.

Right now the handleResults() method in SQLExecutor will when it finds the "end 
of the cursor" while skipping rows break out of the skip loop, try to read the 
next row and start processing rows. When it already reached "end of cursor" in 
the skip loop this read will of course fail, nothing will be processed and the 
method will be exited. (however DB2 will cause an exception to be thrown on the 
read after the loop, as DB2 closes the cursor upon reaching end of cursor).
The fix replaces the break from the skip loop with a return (so that the read 
after the loop is not executed in case the end of cursor has been reached while 
skipping). For non-DB2 databases it's also ok to stop processing then: the end 
of cursor has been reached and no processing will occur anyway.

I've been running this patch in iBATIS for a couple of months without problems, 
and all of the unit test cases still work. It's also only a 1 line change.


> Make PaginatedList work with IBM's broken JDBC driver
> -----------------------------------------------------
>
>          Key: IBATIS-109
>          URL: http://issues.apache.org/jira/browse/IBATIS-109
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.0.8, 2.0.9, 2.1.0, 2.0.9b
>  Environment: Any Java environment
>     Reporter: Patrick Idem
>     Priority: Minor
>  Attachments: SqlExecutor.java
>
> Using DB2 database drivers cases an exception to be thrown when calling 
> paginatedList.next() and the current page is the page before the last page. 
> From what I can determine the PaginatedList class retrieves future records in 
> order to determine if there are any more pages. An Exception will be caused 
> in the following situation:
> A database table has 11 records.
> First issue a command to get a paginated list of all the records with a page 
> size of 10:
> PaginatedList list = queryForPaginatedList("getAllRecords", null, 10)
> Since the paginated list reads ahead it will retrieve all 11 records and 
> reach the end of the ResultSet.
> Now if we want to view the second page (which only consists of 1 record) we 
> would then do the following:
> list.next()
> Now, calling list.next() should not have to go to the database since we had 
> already reached the end of the ResultSet but it does! This is where the 
> problem happens. DB2 drivers automatically close the ResultSet when you read 
> in the last row so the ResultSet has been closed.
> I am suspecting that this problem is only serious when using DB2 drivers but 
> it is still a problem. The paginated list object should be smart enough to 
> know that there are no more results and not try to hit the database that last 
> time.
> The actually DB2 exception that is thrown is the following:
> com.ibm.db2.jcc.a.SqlException: Invalid operation: result set closed

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to