I use SMALLINT columns for booleans for compatibility with other DB's.
However the JDBC driver does not support this.
It can be fixed simply by using '1' and '0' instead of 't' and 'f' in
AbstractJdbc1Statement.setBoolean(int parameterIndex, boolean x)
Actual patch:
cvs diff -wb -i AbstractJdbc1Statement.java (in directory
E:\cvswork\postgresql_jdbc\pgsql-server\src\interfaces\jdbc\org\postgresql\j
dbc1\)
Index: AbstractJdbc1Statement.java
===================================================================
RCS file:
/projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/Abst
ractJdbc1Statement.java,v
retrieving revision 1.17
diff -w -b -i -r1.17 AbstractJdbc1Statement.java
910c910
< bind(parameterIndex, x ? "'t'" : "'f'", PG_BOOLEAN);
---
> bind(parameterIndex, x ? "'1'" : "'0'", PG_BOOLEAN);Met
vriendelijke groet,
Column type test:
castor=> create table testje ( bitje bit, booltje boolean, smallintje int,
intje int );
CREATE TABLE
castor=> insert into testje (bitje, booltje, smallintje, intje) values ('0',
'0', '0', '0');
INSERT 1643931 1
castor=> insert into testje (bitje, booltje, smallintje, intje) values ('1',
'1', '1', '1');
INSERT 1643932 1
castor=> select * from testje;
bitje | booltje | smallintje | intje
-------+---------+------------+-------
0 | f | 0 | 0
1 | t | 1 | 1
(2 rows)
Jeroen Habets
Technology manager
Twofold Mediamarkt
Atlantic House
Westplein 2
3016 BL Rotterdam
The Netherlands
T: +31 (0)20 615 35 64
F: +31 (0)10 214 01 84
M: +31 (0)6 483 55 718
e-mail: jeroen@twofoldmedia.com
website: http://www.twofoldmediamarkt.nl