IsLast () for result set TYPE_FORWARD_ONLY

I am trying to find a way that I would know if I am on the last line of my result set and found the isLast () method.

I did something like:

if(rs.isLast()) { //do some operation here } 

But this causes me an error: the requested operation is not supported only for forward result sets.

I was looking for a solution, and he said that I should change TYPE_FORDWARD_ONLY. But right now I was wondering if there is a way to find out if I hit the last entry using TYPE_FORWARD_ONLY?

Thanks.

+4
source share
3 answers

There is also the isAfterLast method, which you can check after calling next . It is also not required to support TYPE_FORDWARD_ONLY, but you can still try.

+1
source

The connector probably does not support TYPE_FORWARD_ONLY , you can check it using DatabaseMetaData # supports ResultSetType (int) .

0
source

If your driver does not support afterLast and isLast , and you can only use TYPE_FORWARD_ONLY tags, you need to process all the lines, and then do the extra thing that you want to do with the last line after you read all the lines.

0
source

Source: https://habr.com/ru/post/1412523/


All Articles