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 5EEA152800 for ; Tue, 7 Jun 2005 19:58:02 -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 90067-08 for ; Tue, 7 Jun 2005 22:57:57 +0000 (GMT) Received: from gwmta.wicourts.gov (gwmta.wicourts.gov [165.219.244.91]) by svr1.postgresql.org (Postfix) with ESMTP id 1746E52851 for ; Tue, 7 Jun 2005 19:57:56 -0300 (ADT) Received: from Courts-MTA by gwmta.wicourts.gov with Novell_GroupWise; Tue, 07 Jun 2005 17:57:51 -0500 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.2 Date: Tue, 07 Jun 2005 17:57:43 -0500 From: "Kevin Grittner" To: Subject: ResultSet.getObject return type for smallint Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=__PartDDFE3477.0__=" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200506/32 X-Sequence-Number: 12994 --=__PartDDFE3477.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit According to Appendix B of the JDBC spec, ResultSet.getObject should use the mapping shown in table B-3 to determine the object class returned. Table B-3 shows SMALLINT mapping to Integer. In postgresql-jdbc-8.0-311 a Short is returned instead, which is causing problems for our software. It looks like a one-line change will fix this -- in the org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObject method. Index: AbstractJdbc2ResultSet.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v retrieving revision 1.74 diff -u -r1.74 AbstractJdbc2ResultSet.java --- AbstractJdbc2ResultSet.java8 May 2005 23:50:56 -00001.74 +++ AbstractJdbc2ResultSet.java7 Jun 2005 22:53:02 -0000 @@ -115,7 +115,7 @@ case Types.BIT: return getBoolean(columnIndex) ? Boolean.TRUE : Boolean.FALSE; case Types.SMALLINT: - return new Short(getShort(columnIndex)); + return new Integer(getShort(columnIndex)); case Types.INTEGER: return new Integer(getInt(columnIndex)); case Types.BIGINT: --=__PartDDFE3477.0__= Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable =20
According to Appendix B of the JDBC spec, ResultSet.getObject = should use the mapping shown in table B-3 to determine the object class = returned.  Table B-3 shows SMALLINT mapping to Integer.  In = postgresql-jdbc-8.0-311 a Short is returned instead, which is causing = problems for our software.  It looks like a one-line change will fix = this -- in the org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObjec= t method.
 
Index: AbstractJdbc2ResultSet.java
=============== ;================ ;================ ;================ ;========
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/Abstr= actJdbc2ResultSet.java,v
retrieving revision 1.74
diff -u -r1.74 AbstractJdbc2ResultSet.java
--- AbstractJdbc2ResultSet.java8 May 2005 23:50:56 -00001.74
+++ AbstractJdbc2ResultSet.java7 Jun 2005 22:53:02 -0000
@@ -115,7 +115,7 @@
         case Types.BIT:=
           &nb= sp; return getBoolean(columnIndex) ? Boolean.TRUE : = Boolean.FALSE;
         case Types.SMAL= LINT:
-            r= eturn new Short(getShort(columnIndex));
+           &nb= sp;return new Integer(getShort(columnIndex));
         case Types.INTE= GER:
           &nb= sp; return new Integer(getInt(columnIndex));
         case Types.BIGI= NT:
 
--=__PartDDFE3477.0__=--