Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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.

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group