From: Oliver Jowett <oliver@opencloud.com>
To: Christian Cryder <c.s.cryder@gmail.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: smallint mapping issue
Date: Thu, 28 Jul 2005 10:47:16 +1200
Message-ID: <42E80EF4.6000505@opencloud.com> (raw)
In-Reply-To: <90876a9e0507271221246714ac@mail.gmail.com>
References: <90876a9e0507271221246714ac@mail.gmail.com>
Christian Cryder wrote:
> Dave tells me this has been discussed recently, but doesn't recall the
> thread, so I'll post here.
You might want to search on archives.postgresql.org too.
> In postgresql-8.0-311.jdbc3.jar with a column defined as smallint, the
> corresponding value returned from getObject() is a Short.
>
> In the current HEAD, that same smallint column is returned as an Integer.
Please see table B-3 in the JDBC 3.0 spec:
TABLE B-3 JDBC Types Mapped to Java Object Types
ResultSet.getObject and CallableStatement.getObject use the mapping
shown in this table for standard mappings
[...]
TINYINT Integer
SMALLINT Integer
INTEGER Integer
BIGINT Long
> This causes HUGE problems if it's not an oversight, as it makes it
> virtually impossible to write JDBC code that works with other dbs
> (which typically return Short).
Which other DBs exactly? You should tell them to fix their JDBC drivers :)
It's easy enough to deal with both Short and Integer being returned --
cast to java.lang.Number.
> Can someone confirm that this is a bug, and if not, a) why (given the
> above documentation), and b) how do you expect to deal with the
> incompatibility issues this would cause?
It's not a bug -- it's a deliberate change so that we actually follow
the spec.
Personally I'm not prepared to put much effort into supporting backwards
compatibility with old behaviour that was not spec compliant. Fix your
application.
-O
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: oliver@opencloud.com, c.s.cryder@gmail.com
Subject: Re: smallint mapping issue
In-Reply-To: <42E80EF4.6000505@opencloud.com>
References: <90876a9e0507271221246714ac@mail.gmail.com> <42E80EF4.6000505@opencloud.com>
* 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