small bug

From: Christian Roux <christian(dot)roux(at)cegedim-srh(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: small bug
Date: 2007-10-01 13:14:28
Message-ID: 4700F2B4.7030600@cegedim-srh.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi everybody !!!

Driver version : postgresql-8.1-410.jdbc3.jar and
postgresql-jdbc-8.2-506.src.tar.gz
In file org.postgresql.jdbc2.TypeInfoCache :

private static final Object types[][] = {
{"int2", new Integer(Oid.INT2), new Integer(Types.SMALLINT),
"java.lang.Short"},
{"int4", new Integer(Oid.INT4), new Integer(Types.INTEGER),
"java.lang.Integer"},
{"oid", new Integer(Oid.OID), new Integer(Types.INTEGER),
"java.lang.Integer"},
{"int8", new Integer(Oid.INT8), new Integer(Types.BIGINT),
"java.lang.Long"},
{"money", new Integer(Oid.MONEY), new Integer(Types.DOUBLE),
"java.lang.Double"},
{"numeric", new Integer(Oid.NUMERIC), new
Integer(Types.NUMERIC), "java.math.BigDecimal"},
{"float4", new Integer(Oid.FLOAT4), new Integer(Types.REAL),
"java.lang.Float"},
{"float8", new Integer(Oid.FLOAT8), new Integer(Types.DOUBLE),
"java.lang.Double"},
{"bpchar", new Integer(Oid.BPCHAR), new Integer(Types.CHAR),
"java.lang.String"},
{"varchar", new Integer(Oid.VARCHAR), new
Integer(Types.VARCHAR), "java.lang.String"},
{"text", new Integer(Oid.TEXT), new Integer(Types.VARCHAR),
"java.lang.String"},
{"name", new Integer(Oid.NAME), new Integer(Types.VARCHAR),
"java.lang.String"},
{"bytea", new Integer(Oid.BYTEA), new Integer(Types.BINARY),
"java.io.InputStream"},
{"bool", new Integer(Oid.BOOL), new Integer(Types.BIT),
"java.lang.Boolean"},
{"bit", new Integer(Oid.BIT), new Integer(Types.BIT),
"java.lang.Boolean"},
{"date", new Integer(Oid.DATE), new Integer(Types.DATE),
"java.sql.Date"},
{"time", new Integer(Oid.TIME), new Integer(Types.TIME),
"java.sql.Time"},
{"timetz", new Integer(Oid.TIMETZ), new Integer(Types.TIME),
"java.sql.Time"},
{"timestamp", new Integer(Oid.TIMESTAMP), new
Integer(Types.TIMESTAMP), "java.sql.Timestamp"},
{"timestamptz", new Integer(Oid.TIMESTAMPTZ), new
Integer(Types.TIMESTAMP), "java.sql.Timestamp"}

should be

private static final Object types[][] = {
{"int2", new Integer(Oid.INT2), new Integer(Types.SMALLINT),
"java.lang.Short"},
{"int4", new Integer(Oid.INT4), new Integer(Types.INTEGER),
"java.lang.Integer"},
{"oid", new Integer(Oid.OID), new Integer(Types.INTEGER),
"java.lang.Integer"},
{"int8", new Integer(Oid.INT8), new Integer(Types.BIGINT),
"java.lang.Long"},
{"money", new Integer(Oid.MONEY), new Integer(Types.DOUBLE),
"java.lang.Double"},
{"numeric", new Integer(Oid.NUMERIC), new
Integer(Types.NUMERIC), "java.math.BigDecimal"},
{"float4", new Integer(Oid.FLOAT4), new Integer(Types.REAL),
"java.lang.Float"},
{"float8", new Integer(Oid.FLOAT8), new Integer(Types.DOUBLE),
"java.lang.Double"},
{"bpchar", new Integer(Oid.BPCHAR), new Integer(Types.CHAR),
"java.lang.String"},
{"varchar", new Integer(Oid.VARCHAR), new
Integer(Types.VARCHAR), "java.lang.String"},
{"text", new Integer(Oid.TEXT), new Integer(Types.VARCHAR),
"java.lang.String"},
{"name", new Integer(Oid.NAME), new Integer(Types.VARCHAR),
"java.lang.String"},
{"bytea", new Integer(Oid.BYTEA), new Integer(Types.BINARY),
"java.io.InputStream"},
{"bool", new Integer(Oid.BOOL), new Integer(Types.BOOLEAN),
"java.lang.Boolean"},
{"bit", new Integer(Oid.BIT), new Integer(Types.BIT),
"java.lang.Boolean"},
{"date", new Integer(Oid.DATE), new Integer(Types.DATE),
"java.sql.Date"},
{"time", new Integer(Oid.TIME), new Integer(Types.TIME),
"java.sql.Time"},
{"timetz", new Integer(Oid.TIMETZ), new Integer(Types.TIME),
"java.sql.Time"},
{"timestamp", new Integer(Oid.TIMESTAMP), new
Integer(Types.TIMESTAMP), "java.sql.Timestamp"},
{"timestamptz", new Integer(Oid.TIMESTAMPTZ), new
Integer(Types.TIMESTAMP), "java.sql.Timestamp"}

Small code :
create table mytable(
mybool boolean
);

ps = conn.prepareStatement("select count(*) from mytable where mybool =
? ");
System.out.println(ps.getParameterMetaData().getParameterTypeName(1));
----> produce bool
System.out.println(ps.getParameterMetaData().getParameterType(1));
----> produce -7
System.out.println(Types.BOOLEAN); ------> produce 16

So I cant' write :
if (ps.getParameterMetaData().getParameterType(1) == Types.BOOLEAN)

Best regards

Christian

PS

BRAVO for your work !!!!

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message tfinneid 2007-10-01 13:44:49 pg jdbc and dbcp
Previous Message David Gagnon 2007-10-01 10:48:39 Re: rs.getBigDecimal returning Null on field that is not null