Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY? - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
Date
Msg-id BANLkTin9UDRNKV8Pfp_T4x5kqxBcPBKL_Q@mail.gmail.com
Whole thread Raw
In response to Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?  (Steven Schlansker <stevenschlansker@gmail.com>)
List pgsql-jdbc
On 4 June 2011 10:42, Steven Schlansker <stevenschlansker@gmail.com> wrote:

> +    private String determineSQLType(Object[] array) {
> +        Class<?> componentType = array.getClass().getComponentType();
> +        if (componentType.equals(byte.class) || componentType.equals(Byte.class))
> +            return "tinyint";

Note that the test vs. byte, int, etc will never fire, because arrays
of primitive types are not instanceof Object[]

Can we do anything better when given, say, an Object[] (not Integer[])
that contains only Integer instances?
Not sure if you can do anything sensible here, since an Object[] could
also contain a heterogeneous mix of types.

There seems to be some duplication between determineSQLType() and the
switch in setObject().

Oliver

pgsql-jdbc by date:

Previous
From: Steven Schlansker
Date:
Subject: Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
Next
From: Michal Politowski
Date:
Subject: Re: [GENERAL] Mixed up protocol packets in server response?