Unix Technical Forum

moveToInsertRow doesn't work when using prepared statements

This is a discussion on moveToInsertRow doesn't work when using prepared statements within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, calling moveToInsertRow on a ResultSet returned by a prepared statement leads to a NullPointerException: Example code: PreparedStatement p ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:01 PM
Martin Keller
 
Posts: n/a
Default moveToInsertRow doesn't work when using prepared statements

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(Simple Query.java:40)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.parseQ uery(AbstractJdbc2ResultSet.java:1656)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.isUpda teable(AbstractJdbc2ResultSet.java:1516)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkU pdateable(AbstractJdbc2ResultSet.java:2427)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveTo InsertRow(AbstractJdbc2ResultSet.java:868)


Driver Version: 8.0.309 JDBC3
PostgreSQL Version: 7.4.6



Best regards
Martin Keller

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 11:02 PM
Oliver Jowett
 
Posts: n/a
Default Re: moveToInsertRow doesn't work when using prepared statements

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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:27 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com