Re: updatable resultsets -> SQLException: -1

From: Kris Jurka <books(at)ejurka(dot)com>
To: Guido Fiala <guido(dot)fiala(at)dka-gmbh(dot)de>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: updatable resultsets -> SQLException: -1
Date: 2004-01-21 02:11:08
Message-ID: Pine.LNX.4.33.0401202108150.5316-200000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Tue, 20 Jan 2004, Guido Fiala wrote:

> Am Dienstag, 20. Januar 2004 09:13 schrieb Kris Jurka:
> > > "SQLException: -1" - whatever that means...
> > > >java.sql.SQLException: -1 > at
> > > org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateRow(AbstractJdbc2Result
> > >Set.java:1082)
> > >
> >
> > I don't understand what you're saying here. You claim that it works, but
> > it also throws an SQLException? Could we see some more code to produce
> > this? The attached file does not give me any errors.
>
> Yes, exactly so.
>
> The problem is a bit deeper and i have not fully tracked down it yet.
>
> The main thing happening in my code where the problem appears is:
>
> Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
> ResultSet rs = stmt.executeQuery("SELECT * FROM mytesttable FOR UPDATE OF mytesttable;");
>
> rs.updateString(2,"abc");
> rs.updateRow();
> rs.previous();//show some other record
> rs.next();//go back to modified one
> //now the above record has strangely enough vanished from my ResultSet !!!
> //how do i get it back? (the ResulSet gives me at that position the values of the previous-record instead)
> rs.updateString(2,"xyz");
> rs.updateRow();//now i get the SQLException -1
>

You have apparently not navigated back to the original row. The attached
program shows the error you are getting. The error message is completely
unhelpful here, but it is your code that isn't working.

Kris Jurka

Attachment Content-Type Size
updaters2.java text/plain 990 bytes

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Frequency UnKnown 2004-01-21 05:12:41 a little disillusioned
Previous Message Paul Thomas 2004-01-20 19:00:18 Re: Lost connection after postgres restarted