pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steven Schlansker <stevenschlansker@gmail.com>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
Date: Fri, 3 Jun 2011 16:05:45 -0700
Message-ID: <BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.com> (raw)
In-Reply-To: <BANLkTikJ42vWwHutmBdPfAQN6O_ydRiwaA@mail.gmail.com>
References: <AFD63DD9-2CDD-41E5-AB5D-AA6D8A33A59F@gmail.com>
	<BANLkTikJ42vWwHutmBdPfAQN6O_ydRiwaA@mail.gmail.com>


On Jun 3, 2011, at 3:47 PM, Oliver Jowett wrote:

> On 4 June 2011 08:04, Steven Schlansker <stevenschlansker@gmail.com> wrote:
> 
>> It looks like adding support for such a fix to the Postgres driver would be extremely easy.  In particular looking around AbstractJdbc2Statement.java:1732
>> 
>>            case Types.ARRAY:
>>                if (in instanceof Array)
>>                    setArray(parameterIndex, (Array)in);
>>                else
>>                    throw new PSQLException(GT.tr("Cannot cast an instance of {0} to type {1}", new Object[]{in.getClass().getName(),"Types.ARRAY"}), PSQLState.INVALID_PARAMETER_TYPE);
>>                break;
>> 
>> it could check if in is an array type and if so synthesize the Array object necessary.
>> 
>> Does this sound like a reasonable feature request?  Did I miss an easier way to do this?  It is probably outside of the JDBC spec but it at least has some traction with H2...
> 
> How do you determine the type of the (server-side) array elements?
> i.e. what is the typename that setObject would pass to createArrayOf()
> when it encountered an Object[]?

The patch I put in another branch of this thread does basic type introspection.  It handles all the primitive types, wrapped types, and a few SQL types (i.e. Date, Time, Timestamp, byte[])





view thread (8+ messages)  latest in thread

Message-ID: <BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.com>
Permalink:  ../BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.com/
Also on:    postgresql.org/message-id/BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.com

 · 

reply

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: stevenschlansker@gmail.com, oliver@opencloud.com
  Subject: Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
  In-Reply-To: <BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.com>
  References: <AFD63DD9-2CDD-41E5-AB5D-AA6D8A33A59F@gmail.com> <BANLkTikJ42vWwHutmBdPfAQN6O_ydRiwaA@mail.gmail.com> <BBC948C2-9D1F-4651-8D7E-31297217312C@gmail.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