JDBC problem with dates and ANYELEMENT type

Поиск
Список
Период
Сортировка
От Peter
Тема JDBC problem with dates and ANYELEMENT type
Дата
Msg-id 00e701c9c3eb$625d43a0$2717cae0$@com
обсуждение исходный текст
Ответы Re: JDBC problem with dates and ANYELEMENT type
Список pgsql-jdbc
We have a function that takes ANYELEMENT type. If the argument is date (set using setObject(column, datevariable,
Types.DATE))the server throws error: 

ERROR: could not determine polymorphic type because input has type "unknown"

I checked JDBC sources and seems like AbstractJdbc2Statement does this:

    public void setDate(int i, java.sql.Date d, java.util.Calendar cal) throws SQLException
    {
        checkClosed();

        if (d == null)
        {
            setNull(i, Types.DATE);
            return;
        }


        if (cal != null)
            cal = (Calendar)cal.clone();

        // We must use UNSPECIFIED here, or inserting a Date-with-timezone into a
        // timestamptz field does an unexpected rotation by the server's TimeZone:
        //
        // We want to interpret 2005/01/01 with calendar +0100 as
        // "local midnight in +0100", but if we go via date it interprets it
        // as local midnight in the server's timezone:

        // template1=# select '2005-01-01+0100'::timestamptz;
        //       timestamptz
        // ------------------------
        //  2005-01-01 02:00:00+03
        // (1 row)

        // template1=# select '2005-01-01+0100'::date::timestamptz;
        //       timestamptz
        // ------------------------
        //  2005-01-01 00:00:00+03
        // (1 row)

        bindString(i, connection.getTimestampUtils().toString(cal, d), Oid.UNSPECIFIED);
    }



So it indeed sets ‘unspecified’ type which works fine if your target datatype is defined, but fails miserably on
ANYELEMENT.

Any suggestions how to work around this so we can still use ANYELEMENT and pass in DATE?

Peter


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "j.random.programmer"
Дата:
Сообщение: Re: Bug with duplicate column names via JDBC MetaData (ORDINAL_POSITION)
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: JDBC problem with dates and ANYELEMENT type