Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
Дата
Msg-id BANLkTin9UDRNKV8Pfp_T4x5kqxBcPBKL_Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?  (Steven Schlansker <stevenschlansker@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Steven Schlansker
Дата:
Сообщение: Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY?
Следующее
От: Michal Politowski
Дата:
Сообщение: Re: [GENERAL] Mixed up protocol packets in server response?