moveToCurrentRow causes ArrayIndexOutOfBoundsException

Поиск
Список
Период
Сортировка
От Prasanth
Тема moveToCurrentRow causes ArrayIndexOutOfBoundsException
Дата
Msg-id 4241C1EC.8090906@nqadmin.com
обсуждение исходный текст
Ответы Re: moveToCurrentRow causes ArrayIndexOutOfBoundsException  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
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.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: David Gagnon
Дата:
Сообщение: Re: Is that normal I can't commit a transaction when using
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: moveToCurrentRow causes ArrayIndexOutOfBoundsException