smallint mapping issue - Mailing list pgsql-jdbc

From Christian Cryder
Subject smallint mapping issue
Date
Msg-id 90876a9e0507271221246714ac@mail.gmail.com
Whole thread Raw
Responses Re: smallint mapping issue  (Oliver Jowett <oliver@opencloud.com>)
List 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

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: jdbc connection issue in 8.0.3
Next
From: Heikki Linnakangas
Date:
Subject: Re: jdbc xa patches