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