From: fortunasliebling@gmx.de
To: pgsql-jdbc@postgresql.org
Subject: Wrong SqlType for boolean columns
Date: Wed, 28 Jul 2010 09:26:58 +0200
Message-ID: <20100728072658.14770@gmx.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: fortunasliebling@gmx.de
Subject: Re: Wrong SqlType for boolean columns
In-Reply-To: <20100728072658.14770@gmx.net>
References: <20100728072658.14770@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox