From: | Igor Urisman <igor(dot)urisman(at)gmail(dot)com> |
---|---|
To: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
Cc: | "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Improper type conversion from smallint to short |
Date: | 2013-03-18 04:02:12 |
Message-ID: | CAJ9OwnU6W+Wc9=mBXSOe3amkDRvoWArdpFCqp_6pW8cPMs6mLw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Thanks, Kevin & Kris.
I should have looked this up myself. Just seemed hard to fathom that the
following code shouldn't work:
import java.lang.reflect.Field;
...
Field f = reflectFieldOfInterest();
f.set(this, resultSet.getObject("some_column"));
The last statement bombs on Integer to short assignment even though, by my
reckoning, ResultSet.getObject() exists precisely for this use case.
-Igor.
-Igor.
On Fri, Mar 15, 2013 at 5:56 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> Igor Urisman <igor(dot)urisman(at)gmail(dot)com> wrote:
>
> > It appears that ResultSet.getObject(String name) returns Integer
> > for database type Types.SMALLINT (5) I expected Short.
>
> I count on drivers complying with the published specification. The
> most recent version I was able to find near the top of a quick web
> search was this (the Final Release of the JDBC 4.0 Specification):
>
>
> http://download.oracle.com/otn-pub/jcp/jdbc-4.0-fr-eval-oth-JSpec/jdbc-4_0-fr-spec.zip
>
> Take a look at the "Data Type Conversion Tables" in appendix B. In
> particular, table B-3 specifies which Java object class should be
> returned by the getObject methods for each JDBC type. To do as you
> request would break the applications of everyone who trusts the
> specification published through the Java Community Process.
>
> --
> Kevin Grittner
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2013-03-18 22:06:16 | Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47) |
Previous Message | Bryan Varner | 2013-03-16 17:05:46 | Re: Re: [pgjdbc] XADataSource support for resource sharing & interleaving. (#47) |