X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 69F219DC86B for ; Mon, 19 Dec 2005 19:31:54 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07362-06 for ; Mon, 19 Dec 2005 19:31:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by postgresql.org (Postfix) with ESMTP id D94D59DC82E for ; Mon, 19 Dec 2005 19:31:51 -0400 (AST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.21]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EoUTy-0004PM-KR; Tue, 20 Dec 2005 12:31:54 +1300 Message-ID: <43A742F0.8040801@opencloud.com> Date: Mon, 19 Dec 2005 23:32:00 +0000 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "j.random.programmer" CC: pgsql-jdbc@postgresql.org Subject: Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT References: <20051219201451.84589.qmail@web32012.mail.mud.yahoo.com> In-Reply-To: <20051219201451.84589.qmail@web32012.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.04 required=5 tests=[AWL=0.040] X-Spam-Score: 0.04 X-Spam-Level: X-Archive-Number: 200512/86 X-Sequence-Number: 14417 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