From: | Darin Ohashi <DOhashi(at)maplesoft(dot)com> |
---|---|
To: | "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Bug in ResultSet.moveToCurrentRow |
Date: | 2003-06-17 21:12:28 |
Message-ID: | F17255C2B596D3119A5600508B44FA6803BB25D3@courier.maplesoft.on.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I believe there is a bug in ResultSet.moveToCurrentRow with pgsql 7.3.3 and
pgsql-jdbc 7.3.3 build 110. If the current row of the result set is the
beforeFirst() row, call moveToInsertRow() and then moveToCurrentRow(). The
moveToCurrentRow throws an ArrayIndexOutOfBoundsException.
Here is code to reproduce the problem:
import java.sql.*;
import java.util.*;
import java.lang.*;
class SQLBug
{
public static void main( String args[] )
throws Exception
{
Properties prop;
Driver driver;
Connection con;
Statement stat;
ResultSet rs;
driver = (Driver)Class.forName( "org.postgresql.Driver" ).newInstance();
prop = new Properties();
prop.setProperty( "user", "test" );
prop.setProperty( "password", "test" );
con = driver.connect( "jdbc:postgresql://localhost:5432/Test", prop );
stat = con.createStatement();
stat.executeUpdate( "CREATE TABLE sqlbug ( id INTEGER, PRIMARY KEY (id)
)" );
stat.executeUpdate( "INSERT INTO sqlbug(id) VALUES( 1 )" );
stat.executeUpdate( "INSERT INTO sqlbug(id) VALUES( 2 )" );
stat.executeUpdate( "INSERT INTO sqlbug(id) VALUES( 3 )" );
rs = stat.executeQuery( "SELECT * FROM sqlbug WHERE id = 2" );
rs.moveToInsertRow();
/* the following call throws an ArrayIndexOutOfBounds */
rs.moveToCurrentRow();
}
}
The Exception looks like this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1 < 0
at java.util.Vector.elementAt(Vector.java:437)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveToCurrentRow(AbstractJdbc2Result
Set.java:674)
at SQLBug.main(SQLBug.java:42)
Darin
From | Date | Subject | |
---|---|---|---|
Next Message | Casey Kemp | 2003-06-18 00:19:12 | DOWNLOAD JDBC3 |
Previous Message | Nic Ferrier | 2003-06-17 11:50:45 | Re: ResultSet implementation |