Re: PreparedStatement batch statement impossible

Lists: pgsql-jdbc
From: "hans wulf" <lotu1(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org, pg(at)fastcrypt(dot)com
Subject: Re: PreparedStatement batch statement impossible
Date: 2011-03-08 14:17:05
Message-ID: 20110308141705.13350@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

hi,

the API says you can use getGeneratedKeys() after executing the statements. But executeBatch() fails...

The driver has got a problem here:

The normal way would be:

1. Create a PreparedStatement with the GET_GENERATED_KEYS flag
2. executeBatch without Exception
3. call getGeneratedKeys()

--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: hans wulf <lotu1(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement batch statement impossible
Date: 2011-03-08 14:27:44
Message-ID: AANLkTiks02bEgbddt7EBUa-wkxfyqj1LmBqf01LoPtYz@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hans,

It's certainly not clear that this is a requirement of the API. Even
executeBatch is an optional requirement.

Does anyone have any clear direction on how to handle this ? It would
appear that even oracle's jdbc throws an error.

Dave

On Tue, Mar 8, 2011 at 9:17 AM, hans wulf <lotu1(at)gmx(dot)net> wrote:
> hi,
>
> the API says you can use getGeneratedKeys() after executing the statements. But executeBatch() fails...
>
> The driver has got a problem here:
>
> The normal way would be:
>
> 1. Create a PreparedStatement with the GET_GENERATED_KEYS flag
> 2. executeBatch without Exception
> 3. call getGeneratedKeys()
>
>
> --
> GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
> gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
>


From: "hans wulf" <lotu1(at)gmx(dot)net>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement batch statement impossible
Date: 2011-03-08 14:55:03
Message-ID: 20110308145503.204100@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi Dave,

thanks for the quick reply.

without executeBatch the whole JDBC driver is worthless, we don't need a discussion on that :-)

Without being able to get the generatedKeys from an Batch, it is impossible to insert into multiple tables vendor-independently.

Mysql manages this without any problems.

This should be the way to go for the future.

I don't thing I have to tell the story of my ugly code:

if (MYSQL) doThePropperAPIStuff()
else if (POSTGRES) {
1. generate a bulk of future keys
2. pass out these future keys to all entries
}else if (ORACLE){
1. do more a less the same as in POSTGRES but with different Syntax
}

I don't think that sort of code was the intension of JDBC...

-------- Original-Nachricht --------
> Datum: Tue, 8 Mar 2011 09:27:44 -0500
> Von: Dave Cramer <pg(at)fastcrypt(dot)com>
> An: hans wulf <lotu1(at)gmx(dot)net>
> CC: pgsql-jdbc(at)postgresql(dot)org
> Betreff: Re: PreparedStatement batch statement impossible

> Hans,
>
> It's certainly not clear that this is a requirement of the API. Even
> executeBatch is an optional requirement.
>
> Does anyone have any clear direction on how to handle this ? It would
> appear that even oracle's jdbc throws an error.
>
> Dave
>
> On Tue, Mar 8, 2011 at 9:17 AM, hans wulf <lotu1(at)gmx(dot)net> wrote:
> > hi,
> >
> > the API says you can use getGeneratedKeys() after executing the
> statements. But executeBatch() fails...
> >
> > The driver has got a problem here:
> >
> > The normal way would be:
> >
> > 1. Create a PreparedStatement with the GET_GENERATED_KEYS flag
> > 2. executeBatch without Exception
> > 3. call getGeneratedKeys()
> >
> >
> > --
> > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
> > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
> >

--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: hans wulf <lotu1(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PreparedStatement batch statement impossible
Date: 2011-03-09 11:11:37
Message-ID: AANLkTi=NFA2gw5ibmpidYsVdGmMCiLetsz0chHNDd1tW@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tue, Mar 8, 2011 at 9:55 AM, hans wulf <lotu1(at)gmx(dot)net> wrote:
> Hi Dave,
>
> thanks for the quick reply.
>
> without executeBatch the whole JDBC driver is worthless, we don't need a discussion on that :-)
>
> Without being able to get the generatedKeys from an Batch, it is impossible to insert into multiple tables vendor-independently.
>
> Mysql manages this without any problems.
>
> This should be the way to go for the future.
>
> I don't thing I have to tell the story of my ugly code:
>
> if (MYSQL) doThePropperAPIStuff()
> else if (POSTGRES) {
> 1. generate a bulk of future keys
> 2. pass out these future keys to all entries
> }else if (ORACLE){
> 1. do more a less the same as in POSTGRES but with different Syntax
> }
>
> I don't think that sort of code was the intension of JDBC...
>

Well we accept patches. But obviously you aren't going to get away
from if (ORACLE) unless of course you are petitioning them to change
their driver ?

As far as the intention of JDBC, it has lots of ambiguity so it's not
clear that it had any real intention.
Dave
> -------- Original-Nachricht --------
>> Datum: Tue, 8 Mar 2011 09:27:44 -0500
>> Von: Dave Cramer <pg(at)fastcrypt(dot)com>
>> An: hans wulf <lotu1(at)gmx(dot)net>
>> CC: pgsql-jdbc(at)postgresql(dot)org
>> Betreff: Re: PreparedStatement batch statement impossible
>
>> Hans,
>>
>> It's certainly not clear that this is a requirement of the API. Even
>> executeBatch is an optional requirement.
>>
>> Does anyone have any clear direction on how to handle this ? It would
>> appear that even oracle's jdbc throws an error.
>>
>> Dave
>>
>> On Tue, Mar 8, 2011 at 9:17 AM, hans wulf <lotu1(at)gmx(dot)net> wrote:
>> > hi,
>> >
>> > the API says you can use getGeneratedKeys() after executing the
>> statements. But executeBatch() fails...
>> >
>> > The driver has got a problem here:
>> >
>> > The normal way would be:
>> >
>> > 1. Create a PreparedStatement with the GET_GENERATED_KEYS flag
>> > 2. executeBatch without Exception
>> > 3. call getGeneratedKeys()
>> >
>> >
>> > --
>> > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
>> > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
>> >
>
> --
> GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
> gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
>