Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 31CD71337B61 for ; Tue, 23 Nov 2010 17:56:21 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 58052-09 for ; Tue, 23 Nov 2010 21:56:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 662341337B5C for ; Tue, 23 Nov 2010 17:56:13 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PL0qR-0007AO-1x for pgsql-jdbc@postgresql.org; Tue, 23 Nov 2010 22:56:11 +0100 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Nov 2010 22:56:11 +0100 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Nov 2010 22:56:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: bit datatype and getObject() Date: Tue, 23 Nov 2010 22:55:57 +0100 Lines: 26 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.746 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_NUMERIC_HELO=1.164, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/76 X-Sequence-Number: 21197 Hi, the JDBC driver seems to map columns defined as "bit" to Boolean regardless of the definition of the column. So even a bit(5) is returned as boolean value which I think is not correct. Consider the following CREATE TABLE bit_test (some_bits bit(5)); INSERT INTO bit_test VALUES ('01010'); When I run a select in psql it will return 01010 as the column's value. When running a select from within Java and using getObject() on that column a java.lang.Boolean is returned. This might be correct for a bit(1) but not for columns defined with a bigger width. It is returned correctly when using getString() on that column though. But for applications using the generic getObject() this returns a wrong value. I'm not sure what the JDBC specs requires here, but this mapping somehow is confusing. I tested this with PG 9.0 and the JDBC4 build 801 driver. Regards Thomas