pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Prasanth <dbadmin@nqadmin.com>
To: pgsql-jdbc@postgresql.org
Subject: moveToCurrentRow causes ArrayIndexOutOfBoundsException
Date: Wed, 23 Mar 2005 13:22:20 -0600
Message-ID: <4241C1EC.8090906@nqadmin.com> (raw)

Below is a small sample code that I tried out and the results are a little
surprising to me. Is this expected behavior?

In the test code below the query would return zero rows.

I am using jdk1.5.0 with pg74.215.jdbc3.jar and PostgreSQL 7.4.7

TEST 1:

Code Fragment:
String sql = "Select * FROM  test_table WHERE id = -1;";
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = st.executeQuery(sql);
rs.next();
rs.moveToInsertRow();
rs.updateString("client_name", "XYZ");
rs.moveToCurrentRow();

Causes:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
         at java.util.Vector.elementAt(Vector.java:432)
         at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveToCurrentRow(Abstract
Jdbc2ResultSet.java:854)
         at test.<init>(test.java:35)
         at test.main(test.java:86)


Note: Line number 35 is rs.moveToCurrentRow();

TEST 2:
Code Fragment:
String sql = "Select * FROM  test_table WHERE id = -1;";
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = st.executeQuery(sql);
rs.moveToInsertRow();
rs.updateString("client_name", "XYZ");
rs.moveToCurrentRow();

No Exception.



view thread (4+ messages)  latest in thread

Message-ID: <4241C1EC.8090906@nqadmin.com>
Permalink:  ../4241C1EC.8090906@nqadmin.com/
Also on:    postgresql.org/message-id/4241C1EC.8090906@nqadmin.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: dbadmin@nqadmin.com
  Subject: Re: moveToCurrentRow causes ArrayIndexOutOfBoundsException
  In-Reply-To: <4241C1EC.8090906@nqadmin.com>
  References: <4241C1EC.8090906@nqadmin.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox