RE: [INTERFACES] JDBC next() method

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: jbarnett(at)pobox(dot)com, "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>
Subject: RE: [INTERFACES] JDBC next() method
Date: 1999-04-14 13:18:23
Message-ID: A9DCBD548069D211924000C00D001C441D8D3C@exchange.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

This looks ok.

queryResult is null if there was an error in the query, so you should
check for that.

However, normal use would have the result parsed within a
while(queryResult.next()) {} loop, so your interpretation is correct.

Peter

--
Peter T Mount, IT Section
petermount(at)it(dot)maidstone(dot)gov(dot)uk
Anything I write here are my own views, and cannot be taken as the
official words of Maidstone Borough Council

-----Original Message-----
From: Jon Barnett [mailto:jbarnett(at)pobox(dot)com]
Sent: Wednesday, April 14, 1999 1:57 PM
To: 'pgsql-interfaces(at)hub(dot)org'
Subject: [INTERFACES] JDBC next() method

I'm not quite sure about the correct operation of the JDBC next()
method.

Suppose I have the following code:

queryResult = dbStatement.executeQuery("select max(history_id) from
history");
if (queryResult.next())
nextID = queryResult.getLong(1) + 1;
else
nextID = 0;

With the postgresql JDBC driver, the minimum value for nextID is 1, even
if the
history table is empty. I had expected that an empty result set would
be
returned if the history table is empty (0 rows returned for the select),
and
queryResult.next() would be false. Is this an incorrect interpretation
on my
part?

Thanks,

JonB.

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jon Barnett 1999-04-14 14:37:03 RE: [INTERFACES] JDBC next() method
Previous Message Jon Barnett 1999-04-14 12:57:13 JDBC next() method