pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
moveToInsertRow doesn't work when using prepared statements
2+ messages / 2 participants
[nested] [flat]

* moveToInsertRow doesn't work when using prepared statements
@ 2005-01-27 14:00 Martin Keller <martin.keller@unitedplanet.de>
  2005-01-27 21:00 ` Re: moveToInsertRow doesn't work when using prepared statements Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Martin Keller @ 2005-01-27 14:00 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: moveToInsertRow doesn't work when using prepared statements
  2005-01-27 14:00 moveToInsertRow doesn't work when using prepared statements Martin Keller <martin.keller@unitedplanet.de>
@ 2005-01-27 21:00 ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2005-01-27 21:00 UTC (permalink / raw)
  To: Martin Keller <martin.keller@unitedplanet.de>; +Cc: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-01-27 21:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 14:00 moveToInsertRow doesn't work when using prepared statements Martin Keller <martin.keller@unitedplanet.de>
2005-01-27 21:00 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox