From: Dave Cramer <pg@fastcrypt.com>
To: Damon Anderson <anderson@eclipse.knight-rider.org>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bug with 8.X level 4 driver?
Date: Tue, 6 Dec 2005 07:55:22 -0500
Message-ID: <0E851503-1490-4B97-93E5-BA7EC64D96E3@fastcrypt.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0512060024150.2074@eclipse.knight-rider.org>
References: <Pine.LNX.4.64.0512060024150.2074@eclipse.knight-rider.org>
Damon,
Try using batches instead. The new driver can no longer do multiple
statements that way.
Dave
On 6-Dec-05, at 1:40 AM, Damon Anderson wrote:
> Hello,
>
> I currently have a problem with the following statement:
>
> ppS = dd.createPPStatement();
> ppS.setQueryString(
> "INSERT INTO sandwich_side (name) VALUES
> ('pickles');" +
> "INSERT INTO sandwich ( name, sideid) VALUES
> ('club', currval('sandwich_side_id_seq'));" +
> "SELECT currval('sandwich_side_id_seq')");
> Resultset rs = ppS.getPreparedStatement().executeQuery();
> try {
> while( rs.next()) {}
> } catch { SQLException ex1) {
> ex1.printStackTrace();
> }
>
> (This use to work, but updated to 8.X driver (for a unicode issue))
> SQLMessage: No results were returned by the query.
> Statement: Pooled statement wrapping physical statement INSERT INTO
> sandwich_side (name) VALUES ('pickles');INSERT INTO sandwich
> ( name, sideid) VALUES('club', currval
> ('sandwich_side_id_seq'));SELECT currval('sandwich_side_id_seq')
> org.postgresql.util.PSQLException: No results were returned by the
> query.
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery
> (AbstractJdbc2Statement.java:241)
>
> ------------------
>
> So did some searching on the forums, lists, etc.. Changed it to this:
> try
> {
> ppS = dd.createPPStatement();
> ppS.setQueryString(
> "INSERT INTO sandwich_side (name) VALUES
> ('pickles');" +
> "INSERT INTO sandwich ( name, sideid) VALUES
> ('club', currval('sandwich_side_id_seq'));" +
> "SELECT currval('sandwich_side_id_seq')");
> ppS.initStatement(); //Prepares the statement.
> ppS.getPreparedStatement().execute();
> if( ppS.getPreparedStatement().getMoreResults())
> rs = ppS.getPreparedStatement().getResultSet();
> }
> catch (SQLException ex1)
> {
> ex1.printStackTrace();
> }
>
> //ResultSet rs = ppS.getGeneratedKeys();
> try
> {
> while (rs.next()) <-----
> {
> System.err.println("getInt: " + rs.getInt(1));
> }
> }
> catch (SQLException ex) { ex.printStackTrace(); }
>
> So at the moment I can't get the serial id that was created for
> this new insert. The old way with just executeQuery worked great
> (must be 7.X driver). I tried several version of the 8.X driver,
> but all had the same results.
>
> Anyone have the same results? Doing something wrong?
>
> Thanks much,
>
> Damon
> P.S. This is with version 8.0 postgresql server.
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, anderson@eclipse.knight-rider.org
Subject: Re: bug with 8.X level 4 driver?
In-Reply-To: <0E851503-1490-4B97-93E5-BA7EC64D96E3@fastcrypt.com>
References: <Pine.LNX.4.64.0512060024150.2074@eclipse.knight-rider.org> <0E851503-1490-4B97-93E5-BA7EC64D96E3@fastcrypt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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