X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 164E3529A2 for ; Wed, 27 Jul 2005 19:47:16 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97415-10 for ; Wed, 27 Jul 2005 22:47:14 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id A54CA529EF for ; Wed, 27 Jul 2005 19:47:14 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DxugG-0002Fa-GV; Thu, 28 Jul 2005 10:47:16 +1200 Message-ID: <42E80EF4.6000505@opencloud.com> Date: Thu, 28 Jul 2005 10:47:16 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christian Cryder Cc: "pgsql-jdbc@postgresql.org" Subject: Re: smallint mapping issue References: <90876a9e0507271221246714ac@mail.gmail.com> In-Reply-To: <90876a9e0507271221246714ac@mail.gmail.com> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/379 X-Sequence-Number: 13527 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