Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT
Дата
Msg-id 43A742F0.8040801@opencloud.com
обсуждение исходный текст
Ответ на Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT correctly  ("j.random.programmer" <javadesigner@yahoo.com>)
Ответы Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT correctly
Список pgsql-jdbc
j.random.programmer wrote:
> Running against postgres 8.1
>
> I have:
>
> create table foo (bit_val bit);
>
> If I now try to insert, via the driver's prepared
> statement, a value of java boolean true into
> the bit_val column, I get:
>
> ---------------------------------
> ERROR COULD NOT SAVE.....
> org.postgresql.util.PSQLException: ERROR: column
> "bit_val" is of type bit but expression is of type
> boolean
> ---------------------------------

JDBC's "BIT" is actually a boolean type. In JDBC3, BIT and BOOLEAN are
effectively equivalent.

The backend's "bit" type is actually a bitstring that does not have a
direct equivalent in JDBC.

> This is totally wrong if my reading of the JDBC
> spec is correct. Java boolean values should
> be converted to bitval(1), possibly as '1' and
> then converted back to boolean when read from
> the database.

Actually, the spec says nothing about bitstring types AFAIK.

If you want to do this type conversion and still use setBoolean(), you
will need to modify your query to do the type conversion there.

-O

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

Предыдущее
От: Oliver Jowett
Дата:
Сообщение: Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString()
Следующее
От: "j.random.programmer"
Дата:
Сообщение: Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy