From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | "j(dot)random(dot)programmer" <javadesigner(at)yahoo(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT |
Date: | 2005-12-19 23:32:00 |
Message-ID: | 43A742F0.8040801@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | j.random.programmer | 2005-12-19 23:36:08 | Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy |
Previous Message | Oliver Jowett | 2005-12-19 23:28:48 | Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() |