[ 
http://issues.apache.org/jira/browse/IBATIS-109?page=comments#action_65434 ]
     
Clinton Begin commented on IBATIS-109:
--------------------------------------


Typical IBM garbage.  Why must they be different?  So lame.  

The ResultSet interface clearly describes when a ResultSet should be 
automatically closed.

-------------------------------
public void close()
           throws SQLException

Releases this ResultSet object's database and JDBC resources immediately 
instead of waiting for this to happen when it is automatically closed.

Note:  A ResultSet object is automatically closed by the Statement object that 
generated it when that Statement object is closed, re-executed, or is used to 
retrieve the next result from a sequence of multiple results. A ResultSet 
object is also automatically closed when it is garbage collected.

Throws:  SQLException - if a database access error occurs 

--------------------------------

Seems pretty clear to me.  The connection should NOT be automatically closed 
just because the end of the record set has been reached.  Furthermore, the 
behaviour of .next() is pretty clear with how "no more rows" should be 
communicated:

--------------------------------
public boolean next()
             throws SQLException

    Moves the cursor down one row from its current position. A ResultSet cursor 
is initially positioned before the first row; the first call to the method next 
makes the first row the current row; the second call makes the second row the 
current row, and so on.

    If an input stream is open for the current row, a call to the method next 
will implicitly close it. A ResultSet object's warning chain is cleared when a 
new row is read.

    Returns:
        true if the new current row is valid; false if there are no more rows 
    Throws:
        SQLException - if a database access error occurs
--------------------------------

This is a bug in the IBM driver.  

That said, I'll leave this open as a feature request.  For now, I agree with 
Brandon, you should probably be useing queryForList() with offset and length 
params.

Cheers,
Clinton

> PaginatedList bug
> -----------------
>
>          Key: IBATIS-109
>          URL: http://issues.apache.org/jira/browse/IBATIS-109
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Versions: 2.0.8, 2.0.9, 2.0.9b, 2.1.0, 2.1.1, 2.1.2
>  Environment: Any Java environment
>     Reporter: Patrick Idem
>     Priority: Critical

>
> 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