Re: setObject(...) with native Java arrays like String[] ?

From: dmp <danap(at)ttc-cmc(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: setObject(...) with native Java arrays like String[] ?
Date: 2012-08-22 15:18:15
Message-ID: 5034F837.7060103@ttc-cmc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> On 22/08/2012 04:09, Craig Ringer wrote:
>>
>> I was recently surprised to find that PgJDBC doesn't accept Java
>> arrays as parameters to prepared statements.

I'm not surprised at this behavior since I needed to support all data
types with the MyJSQLView application for PostgreSQL. The app uses
prepare statements for inserts/updates and I found out very early
that all data types needed to be explicitly stated for prepare statements.
This is not the JDBC from my understanding, but rather the PostgreSQL
server. You can get away with this in other databases, but not so for
PostgreSQL.

One way around this I found is send the data with the initial prepare
statement creation. This of course precludes recursive use then of the
statement. Kinda defeats the purpose, but for singluar inserts/update
works fine.

It looks like from your code the arrays you speak of are not java.sql.Array?

> John Lister wrote:
> As was I, I posted a patch a couple of months ago that did the same
> thing but also accepted java List types as well (I'm often using these
> especially with JPA and it would be nice to pass them into the driver),
> although it seems to have been silently ignored. Maybe I'll repost it.

John, the Silence I think is not purposeful. With the port to GIT does
this not allow contributors to more easily process patches independently?
I'm not that familiar with GIT so I apologize up front for my ignorance.

danap.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2012-08-23 01:32:10 Re: setObject(...) with native Java arrays like String[] ?
Previous Message John Lister 2012-08-22 06:39:56 Re: setObject(...) with native Java arrays like String[] ?