Subject Re: [Firebird-Java] Update WHERE CURRENT OF vs. ResultSet.isLast()
Author Nickolay Samofatov
Hello, Roman,

> I've got a request about implementing Statement.setCursorName(String)
> and using positioned updates. While implementing this stuff I
> discovered that with positioned updates we cannot have
> ResultSet.isLast() working.

> Reason for this is that server does not tell us anything whether we
> fetched the last record or not. This happens only during additional
> fetch() (we get reply "sorry, no more records"). Till now we
> prefetched one record, but this moves cursor position too. So, when
> using positioned update we would update next records, not current.
> Fixing this prefetching breaks ResultSet.isLast().

> Usually people use while(rs.next()) {...} construct, so broken
> rs.isLast() would not affect them. However if you use do {rs.next()}
> while(!rs.isLast()), you will get endless loop.

> So, the question now is: what do you prefer - positioned updates or
> correct work of ResultSet.isLast()? Should I create a poll in the group?

There is a way to implement JDBC spec while providing positioned
updates. Do not pre-fetch additional record during normal fetch.
Do it in ResultSet.isLast() method instead. While implementing
getCursorName() clearly state in its documentation that isLast()
method moves the physical cursor (while logical position remains the
same). Thats it.

> Roman Rokytskyy


Nickolay Samofatov