pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
unusual ResultSet.next() behaviour
4+ messages / 4 participants
[nested] [flat]

* unusual ResultSet.next() behaviour
@ 2005-07-27 05:00  Les Carter <carterl@newkinetics.com>
  0 siblings, 3 replies; 4+ messages in thread

From: Les Carter @ 2005-07-27 05:00 UTC (permalink / raw)
  To: pgsql-jdbc

This is a multi-part message in MIME format.

--bound1122440425
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Consider the following code snippet where rs is a ResultSet object obtained from a previous query:<br /><br />    for(int count=0; count!=someValue; count++)<br />    {<br />        if(!rs.next()) throw SomeException();<br />    }<br />    rs.next();<br /><br />Pretty simple, just cycle through someValue number of records and then get the next record after that.  For some reason, say if the query has 20 rows that will be returned, and I set someValue to be 5 for arguments sake, it will go through the for loop with no problems, but when it comes out of the for loop and tries to the next rs.next() operation it always returns false.  I can increase someValue to 10 and it will still loop without a problem, but it will always return false for that rs.next() operation following the for loop.<br /><br />I can't see any rational reason for this.  I'm using PostgreSQL 8.0 and the JDBC 3 drivers on Win XP with JDK 1.42_06.  The ResultS!
 et is a proxy object gained from a JBoss4.0 supplied connection pool.<br /><br />Can anyone offer any explanation, or repeat the simple steps to confirm I'm not loosing my sanity?<br /><br />Cheers,<br /><br />L<br />

--bound1122440425--




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: unusual ResultSet.next() behaviour
@ 2005-07-27 14:46  Jan de Visser <jdevisser@digitalfairway.com>
  parent: Les Carter <carterl@newkinetics.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Jan de Visser @ 2005-07-27 14:46 UTC (permalink / raw)
  To: pgsql-jdbc

First off, you need a different e-mail client. The one you're using makes a 
royal mess of MIME messages. Please stop using it (at least don't use it to 
send to this list :)


On Wednesday 27 July 2005 01:00, Les Carter wrote:
> Consider the following code snippet where rs is a ResultSet object obtained
> from a previous query:
>
>     for(int count=0; count!=someValue; count++)
>     {
>         if(!rs.next()) throw SomeException();
>     }
>     rs.next();
>
> Pretty simple, just cycle through someValue number of records and then get
> the next record after that.  For some reason, say if the query has 20 rows
> that will be returned, and I set someValue to be 5 for arguments sake, it
> will go through the for loop with no problems, but when it comes out of the
> for loop and tries to the next rs.next() operation it always returns
> false.  I can increase someValue to 10 and it will still loop without a
> problem, but it will always return false for that rs.next() operation
> following the for loop.
>
> I can't see any rational reason for this.  I'm using PostgreSQL 8.0 and the
> JDBC 3 drivers on Win XP with JDK 1.42_06.  The ResultS! et is a proxy
> object gained from a JBoss4.0 supplied connection pool.
>
> Can anyone offer any explanation, or repeat the simple steps to confirm I'm
> not loosing my sanity?

Works for me. I don't see what you're experiencing; my next() after the loop 
returns true.

>
> Cheers,
>
> L

JdV!!

-- 
--------------------------------------------------------------
Jan de Visser                     jdevisser@digitalfairway.com

                Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: unusual ResultSet.next() behaviour
@ 2005-07-27 22:33  Oliver Jowett <oliver@opencloud.com>
  parent: Les Carter <carterl@newkinetics.com>
  2 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2005-07-27 22:33 UTC (permalink / raw)
  To: Les Carter <carterl@newkinetics.com>; +Cc: pgsql-jdbc

Les Carter wrote:

> Can anyone offer any explanation, or repeat the simple steps to confirm
> I'm not loosing my sanity?

Well, if you could give us an actual testcase we could test it.. as it
is your explanation is very vague. I'm not aware of any problems with
the return value of next(), and it's a pretty fundamental bit of the API
so I'd be suprised if something was wrong here and none of the
regression tests failed.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: unusual ResultSet.next() behaviour
@ 2005-07-28 12:56  emergency.shower@gmail.com <emergency.shower@gmail.com>
  parent: Les Carter <carterl@newkinetics.com>
  2 siblings, 0 replies; 4+ messages in thread

From: emergency.shower@gmail.com @ 2005-07-28 12:56 UTC (permalink / raw)
  To: pgsql-jdbc

On 7/27/05, Les Carter <carterl@newkinetics.com> wrote:
> This is a multi-part message in MIME format. --bound1122440425 Content-Type:
> text/html; charsetiso-8859-1 Content-Transfer-Encoding: quoted-printable
> Consider the following code snippet where rs is a ResultSet object obtained
> from a previous query:
> 
>     for(int count=0; count!=someValue; count++)
>     {
>         if(!rs.next()) throw SomeException();
>     }
>     rs.next();
> 
> Pretty simple, just cycle through someValue number of records and then get
> the next record after that.

I suspect that this isn't the code that actually produces the error.
If SomeException() is a constructor, this code wouldn't compile. Could
you post a more complete snippet?

-Alex



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-07-28 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 05:00 unusual ResultSet.next() behaviour Les Carter <carterl@newkinetics.com>
2005-07-27 14:46 ` Jan de Visser <jdevisser@digitalfairway.com>
2005-07-27 22:33 ` Oliver Jowett <oliver@opencloud.com>
2005-07-28 12:56 ` emergency.shower@gmail.com <emergency.shower@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox