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 9FB2B9DC81B for ; Wed, 21 Dec 2005 00:41:32 -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 42958-08 for ; Wed, 21 Dec 2005 00:41:31 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web32013.mail.mud.yahoo.com (web32013.mail.mud.yahoo.com [68.142.207.110]) by postgresql.org (Postfix) with SMTP id D4FFA9DCB85 for ; Wed, 21 Dec 2005 00:41:29 -0400 (AST) Received: (qmail 56247 invoked by uid 60001); 21 Dec 2005 04:41:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=n9a990vkjRSLjFPaIhzJlH3B4Ao5uLwxn+uorwyww4dsWj3PODy96w89wQb3ANAKzv15BlnXW2vf9aRIPxx8mdup/J/6K3pYfjiYar3ipVF98x61toogFg0DCIAyHmse91cVZHgisT9YPAl9Y9O6OegOGpOGgBOYtHsDhddn6vU= ; Message-ID: <20051221044129.56245.qmail@web32013.mail.mud.yahoo.com> Received: from [141.151.82.94] by web32013.mail.mud.yahoo.com via HTTP; Tue, 20 Dec 2005 20:41:29 PST Date: Tue, 20 Dec 2005 20:41:29 -0800 (PST) From: "j.random.programmer" Subject: Re: Bug: Driver(8.2dev-500.jdbc3) does not handle boolean->BIT correctly To: oliver@opencloud.com, pg@fastcrypt.com Cc: pgsql-jdbc@postgresql.org In-Reply-To: <43A7ACCC.3020601@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.479 X-Spam-Level: X-Archive-Number: 200512/100 X-Sequence-Number: 14431 Ok. This while BIT thing is very non-intuitive from my perspective. First consider this: In PSQL: -------------------------------------- test=# create table foo (bit_val bit(5)); CREATE TABLE test=# insert into foo (bit_val) values ('B10101'); INSERT 0 1 test=# insert into foo (bit_val) values ('11111'); INSERT 0 1 test=# select * from foo; bit_val --------- 10101 11111 (2 rows) ------------------------------------ Value 'B11110' IS 100% valid according to the postgresql manual. (for a BIT(5) column type). Now, from JDBC this is impossible. BOTH of the following give exceptions and error out. With val = '11111' ------------------------------------ PreparedStatement pstmt = con.prepareStatement( "insert into foo (bit_val) values (?)" ); pstmt.setString(1, val); pstmt.executeUpdate(); ----------------------------------- The same with val = 'B11111' The same with val = true ...etc... SQLException: SQLState(42804) Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "bit_val" is of type bit but expression is of type character varying at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1514) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1299) ------------------------------------- As far as I can tell, this is a big problem. Or am I missing something ? [Is there *ANY* way to get a value into a BIT column from JDBC via preparedstatements ?] Best regards, --j __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com