Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C4021632AC1 for ; Wed, 28 Jul 2010 04:27:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 56221-08 for ; Wed, 28 Jul 2010 07:27:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id 2F1E46323E9 for ; Wed, 28 Jul 2010 04:27:02 -0300 (ADT) Received: (qmail 1590 invoked by uid 0); 28 Jul 2010 07:27:00 -0000 Received: from 83.236.206.178 by www098.gmx.net with HTTP; Wed, 28 Jul 2010 09:26:57 +0200 (CEST) Content-Type: text/plain; charset="utf-8" Date: Wed, 28 Jul 2010 09:26:58 +0200 From: fortunasliebling@gmx.de Message-ID: <20100728072658.14770@gmx.net> MIME-Version: 1.0 Subject: Wrong SqlType for boolean columns To: pgsql-jdbc@postgresql.org X-Authenticated: #38021177 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX18ZxrMzVEMZDlOW/1h+y9NWCwoaUszIW8QqTdLNyn XqPkN8horYcQEaLK4U/0JF6bRbvLj/GGiFFQ== Content-Transfer-Encoding: 8bit X-GMX-UID: lb49bKFkeSEqVlhLL3YhiKR+IGRvbwDX X-FuHaFi: 0.5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.8 tagged_above=-10 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201007/113 X-Sequence-Number: 20778 Hello everyone, i found out that my postgres driver maps a boolean column to the sqlType -7, wich is java.sql.Types.BIT and not java.sql.Types.Boolean (Boolean is 16). This is a very strange behavior. I think this is a bug within the jdbc-driver. link to JavaDoc: http://java.sun.com/javase/6/docs/api/constant-values.html#java.sql.Types.BOOLEAN the code i used to test this: //returns a connection to the database Connection con = ConnectionManager.getConnection(); PreparedStatement prep = con.prepareStatement("select isboolean from test"); ResultSet rs = prep.executeQuery(); ResultSetMetaData rsmd = rs.getMetaData(); System.out.println(rsmd.getColumnType(1)); System.out.println(rsmd.getColumnTypeName(1)); rs.close(); prep.close(); con.close(); definition of table: CREATE TABLE test ( id serial NOT NULL, "name" character varying NOT NULL DEFAULT ''::character varying, "number" integer DEFAULT 1, date date DEFAULT now(), isboolean boolean DEFAULT true, CONSTRAINT test_pkey PRIMARY KEY (id) ) the output of this program is: -7 bool but it should be: 16 bool I tested this with: postgresql-8.3-605.jdbc3.jar postgresql-8.4-701.jdbc3.jar postgresql-8.4-701.jdbc4.jar Server is PostgreSQL 8.4.4 on x86_64-pc-linux-gnu by gcc4-4.real (Ubuntu)... Im using java-sdk 6. greetings Michael -- Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail