Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31548

Re: JDBC: scroll cursor "broken" after fetch absolute beyond end?

From Marcel Mueller <news.5.maazl@spamgourmet.org>
Newsgroups comp.lang.java.programmer
Subject Re: JDBC: scroll cursor "broken" after fetch absolute beyond end?
Date 2015-04-10 16:52 +0200
Organization MB-NET.NET for Open-News-Network e.V.
Message-ID <mg8o33$oud$1@gwaiyur.mb-net.net> (permalink)
References <slrnmifbpd.uoi.avl@login.logic.tuwien.ac.at>

Show all headers | View raw


On 10.04.15 13.07, Andreas Leitgeb wrote:
> Given a scroll-cursor (as in: "ResultSet.TYPE_SCROLL_SENSITIVE"), my
> application attempts to move the ResultSet to absolute position 100
> just to see, if there are at least 100 rows. Later it calls rs.first()
> on the ResultSet to reposition back to start for getting the rows.
>
> If the actual number of result rows is only 10, then positioning with
> absolute(100) returns false -- so far, so good.
>
> After that, however, repositioning to row 1 also returns false!
> This is what I don't understand.  There are definitely 10 rows.

Did you do some commit in between? This can destroy cursors.

If not, the JDBC driver might be buggy or has restrictions. You might 
want to create a bug report with a small test case.

Maybe you can use beforeFirst() as work around. It resets the cursor to 
its initial state.

> Reading the docs, I'd have expected that fetching beyond the edge
> would just leave the cursor one after last row, and ready to be again
> repositioned to any other (valid) row.

If you are talking about the Oracle docs I agree.

> PS: whether attempting an rs.absolute(100) is the most elegant approach
>    to checking for "at least 100 rows" is not so much the question here,

Indeed, it is more likely a very inefficient way.

> PPS: this is with informix, but I'd also be interested about
>    experience with that scenario on any other DB ...

No idea, I never used this pattern.


Marcel

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JDBC: scroll cursor "broken" after fetch absolute beyond end? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-04-10 11:07 +0000
  Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-04-10 16:52 +0200
    Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-04-12 22:10 +0000
      Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Martin Gregorie <martin@address-in-sig.invalid> - 2015-04-12 23:17 +0000
      Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2015-04-13 01:34 +0200
      Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2015-07-20 22:26 +0000
  Re: JDBC: scroll cursor "broken" after fetch absolute beyond end? Arne Vajhøj <arne@vajhoej.dk> - 2015-04-12 21:51 -0400

csiph-web