moveToInsertRow doesn't work when using prepared statements

Lists: pgsql-jdbc
From: Martin Keller <martin(dot)keller(at)unitedplanet(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: moveToInsertRow doesn't work when using prepared statements
Date: 2005-01-27 14:00:46
Message-ID: 200501271500.46617.martin.keller@unitedplanet.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello,

calling moveToInsertRow on a ResultSet returned by a prepared statement leads
to a NullPointerException:

Example code:

PreparedStatement p = c.prepareStatement(
"SELECT * FROM sampletable WHERE myid=?",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);

p.setInt(1,1);

ResultSet r = p.executeQuery();

r.moveToInsertRow();

Result:

Exception in thread "main" java.lang.NullPointerException
at org.postgresql.core.v3.SimpleQuery.toString(SimpleQuery.java:40)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.parseQuery(AbstractJdbc2ResultSet.java:1656)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.isUpdateable(AbstractJdbc2ResultSet.java:1516)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkUpdateable(AbstractJdbc2ResultSet.java:2427)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveToInsertRow(AbstractJdbc2ResultSet.java:868)

Driver Version: 8.0.309 JDBC3
PostgreSQL Version: 7.4.6

Best regards
Martin Keller


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Martin Keller <martin(dot)keller(at)unitedplanet(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: moveToInsertRow doesn't work when using prepared statements
Date: 2005-01-27 21:00:41
Message-ID: 41F95679.8030004@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Martin Keller wrote:

> calling moveToInsertRow on a ResultSet returned by a prepared statement leads
> to a NullPointerException:

Thanks for the report, fixed in CVS.

A workaround is to specify protocolVersion=2 in the connection URL, as
the V2 protocol code is correct (it looks like that change wasn't made
in both paths when I was originally writing this code)

-O