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