Re: Problem with executeBatch and "A result was returned when none was expected" - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Problem with executeBatch and "A result was returned when none was expected"
Date
Msg-id AANLkTimWSO4QG7+n9eyXgbNx6-jETXJp2TC66-gFXE8F@mail.gmail.com
Whole thread Raw
In response to Re: Problem with executeBatch and "A result was returned when none was expected"  (Lew <noone@lewscanon.com>)
List pgsql-jdbc
On 19 March 2011 11:47, Lew <noone@lewscanon.com> wrote:
> Oliver Jowett wrote:

> This is the documented result when a statement tries to create a result set:
> "Throws BatchUpdateException (a subclass of SQLException) if one of the
> commands sent to the database fails to execute properly or attempts to
> return a result set."

However, the query that the app provided was just a simple INSERT,
which does not return a result set, so this isn't really relevant
here. If the driver decides to transform the query, it's also
responsible for cleaning the mess up afterwards!

>> You are correct, generated keys don't work with executeBatch() yet.
>> (There was another thread about this a couple of days ago)
>
> How would you retrieve the result if 'executeBatch()' did what you're
> asking?

Via getGeneratedKeys(). The driver already knows that it added the
RETURNING clause to implement Statement.RETURN_GENERATED_KEYS, and it
deals with the eventual resultset in the simple query execution path
(so that it looks to the caller as if the original query executed with
no RETURNING clause). The missing piece is equivalent code for the
batch execution path.

Oliver

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Problem with executeBatch and "A result was returned when none was expected"
Next
From: Sean Bowman
Date:
Subject: Re: Problem with executeBatch and "A result was returned when none was expected"