updatable resultsets -> SQLException: -1 - Mailing list pgsql-jdbc

From Guido Fiala
Subject updatable resultsets -> SQLException: -1
Date
Msg-id 200401200846.51519.guido.fiala@dka-gmbh.de
Whole thread Raw
Responses Re: updatable resultsets -> SQLException: -1  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
hallo all,

i have a problem getting updatable resultsets working
(Postgres 7.3.4, current pg73jdbc3.jar)

basically i do:

try {
    Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    Resultset rs=stmt.executeQuery("Select * from sometable;");
    rs.first();//in my example it exists
    rs.updateInt("some_int",4);
    rs.updateString("some_string","some_value");
    rs.updateRow();
} catch ( SQLException e ) {
    e.printStackTrace();
}

In that case i get an SQLException "no primary keys" whereas sometable definitely has primary key!!!

>java.sql.SQLException: No Primary Keys
>    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.isUpdateable(AbstractJdbc2ResultSet.java:1369)
>    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSet.java:996)

i tracked this down and found that using:

Resultset rs=stmt.executeQuery("Select * from sometable for update of sometable;");

let's me indeed update the values in the table (even if the resultset is opened not-CONCUR_UPDATABLE) !!,
however there is still an "SQLException: -1" - whatever that means...

>java.sql.SQLException: -1
>    at org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2ResultSet.java:1082)
>...

Any hints?

Guido


pgsql-jdbc by date:

Previous
From: "Frequency UnKnown"
Date:
Subject: JDBC woes SOLVED!!!
Next
From: Kris Jurka
Date:
Subject: Re: updatable resultsets -> SQLException: -1