Re: NullPointerExceptions in empty ResultSets

From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: <floyds(at)4peakstech(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: NullPointerExceptions in empty ResultSets
Date: 2002-06-17 12:41:31
Message-ID: NEBBLAAHGLEEPCGOBHDGOEFMFCAA.nickf@ontko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Floyd-

We really need to see a chunk of the relevant code to be very helpful, but
my first impression is that this is probably not a driver problem, as I'm
using resultsets with no problems on the current driver.

Perhaps we are using a different approach in our code. I usually have any
reference to a ResultSet wrapped in a test- for instance:

ResultSet results = someStatement.executeQuery();
if (results.next())
{
/*Something is there, so do something with it
}
else
{
/*report no results returned*/
}

OR:

ResultSet results = someStatement.executeQuery();
while(results.next())
{
/*Something is there, so loop through all of the somethings.
}
else
{
/*report no results returned*/
}

Do you use a similar approach to testing for contents before using?

Regards,

-Nick

--------------------------------------------------------------------------
Nick Fankhauser nickf(at)ontko(dot)com Phone 1.765.935.4283 Fax 1.765.962.9788
Ray Ontko & Co. Software Consulting Services http://www.ontko.com/

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Floyd Shackelford
Sent: Thursday, June 13, 2002 12:59 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] NullPointerExceptions in empty ResultSets

i just upgraded to the latest jdbc driver and am now getting errors in empty
ResultSets (i.e. the sql select returned 0 rows) where i used to not get an
error. here are some examples:

java.lang.NullPointerException at
org.postgresql.jdbc2.ResultSet.beforeFirst(ResultSet.java:876)

java.lang.NullPointerException at
org.postgresql.jdbc2.ResultSet.last(ResultSet.java:1133)

please let me know if this is an error and if so:

1. how do i work around it for now
2. when can i have a new version of the jdbc jar file?

Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX: 916.404.7125
EMAIL: FloydS(at)4PeaksTech(dot)com
ICQ #: 161371538
acta non verba

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-06-17 13:58:05 Re: JBuilder 6 & JDBC
Previous Message Barry Lind 2002-06-17 10:09:04 [Fwd: [Fwd: Re: solved: fastpath error?]]