Skip site navigation (1) Skip section navigation (2)

updatable resultsets -> SQLException: -1

From: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: updatable resultsets -> SQLException: -1
Date: 2004-01-20 07:46:51
Message-ID: 200401200846.51519.guido.fiala@dka-gmbh.de (view raw or flat)
Thread:
Lists: 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


Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-01-20 08:13:23
Subject: Re: updatable resultsets -> SQLException: -1
Previous:From: Frequency UnKnownDate: 2004-01-20 04:53:06
Subject: JDBC woes SOLVED!!!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group