Re: previous throws

Lists: pgsql-jdbc
From: "Keith Bottner" <kbottner(at)comcast(dot)net>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: previous throws
Date: 2003-12-30 01:18:06
Message-ID: 000001c3ce72$c7e8eb30$7d00a8c0@juxtapose
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Although I have been using postgres for a while I just recently started
using the JDBC driver. I found after retrieving a result set, calling
afterLast() and then calling previous() a java.lang.NullPointerException is
thrown. Looking at the source for previous in AbstractJdbc2ResultSet.class

public boolean previous() throws SQLException {
if (--current_row < 0)
return false;
this_row = (byte[][]) rows.elementAt(current_row);
System.arraycopy(this_row, 0, rowBuffer, 0, this_row.length);
return true;
}

the rowBuffer is never allocated and is null which actually causes the
error. All other methods that use rowBuffer include a line that resembles
this:\

rowBuffer = new byte[this_row.length][];

If I call any other method that allocates rowBuffer then previous works
fine. So in short, should I be calling another method prior to calling
previous to initialize the rowBuffer? I believe that this is a bug, and it
is present in the most current driver, but I wanted to run it by the JDBC
list to make sure before submitting the fix.

Thanks,

Keith


From: Kris Jurka <books(at)ejurka(dot)com>
To: Keith Bottner <kbottner(at)comcast(dot)net>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: previous throws
Date: 2003-12-30 01:26:54
Message-ID: Pine.LNX.4.33.0312292024100.16660-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 29 Dec 2003, Keith Bottner wrote:

> Although I have been using postgres for a while I just recently started
> using the JDBC driver. I found after retrieving a result set, calling
> afterLast() and then calling previous() a java.lang.NullPointerException is
> thrown. Looking at the source for previous in AbstractJdbc2ResultSet.class

I fixed this in bug in early November, but it didn't get backpatched to
the 7.4 branch until the middle of December to make the 7.4.1 release.

Kris Jurka