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.