smallint mapping issue

From: Christian Cryder <c(dot)s(dot)cryder(at)gmail(dot)com>
To: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: smallint mapping issue
Date: 2005-07-27 19:21:04
Message-ID: 90876a9e0507271221246714ac@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi guys,

Dave tells me this has been discussed recently, but doesn't recall the
thread, so I'll post here.

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.

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).

From the JDK 1.5 docs (and all the previous ones as well):
http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/mapping.html
---------------------------------
8.3.5 SMALLINT

The JDBC type SMALLINT represents a 16-bit signed integer value
between -32768 and 32767.

The corresponding SQL type, SMALLINT, is defined in SQL-92 and is
supported by all the major databases. The SQL-92 standard leaves the
precision of SMALLINT up to the implementation, but in practice, all
the major databases support at least 16 bits.

The recommended Java mapping for the JDBC SMALLINT type is as a Java short.
---------------------------------

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?

Thanks,
Christian

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Heikki Linnakangas 2005-07-27 19:40:52 Re: jdbc xa patches
Previous Message Dave Cramer 2005-07-27 16:52:26 Re: jdbc connection issue in 8.0.3