Thank you, Knut, for your prompt response.
However, such asymmetry (java.lang.Short->SMALLINT->java.lang.Integer) is causing trouble in my code and will require inefficient type checking to override such behavior.

From: Knut Anders Hatlen <>
To: "Derby Discussion" <>
Date: 07/26/2011 04:13 PM
Subject: Re: ResultSet.getObject(int) for SMALLINT returns Integer, not Short

Pavel Bortnovskiy <> writes:

> Hello:
> Can you please tell me whether this behavior expected or is it a bug?
> 1. a table with SMALLINT is created:
> 2. values are inserted and Java Short datatype is used to set SMALLINT
> values
> 3. values in the table are read with a PreparedStatement "select *
> from Test_Table" and then read with:
> while ( {
>         final Object object = resultSet.getObject(columnIdx);
> }
> 4. at which point, resultSet.getMetaData().getColumnType(columnIdx) ==
> SMALLINT, but object.getClass() is java.lang.Integer, whereas I would
> be expecting java.lang.Short.

Hi Pavel,

java.lang.Integer is the correct type for SMALLINT. See table B-3
(Mapping from JDBC Types to Java Object Types) in the JDBC 4.0

There's a note in the specification saying that this mapping is for
compatibility with JDBC 1.0, which was finalized before java.lang.Byte
and java.lang.Short were added to the Java language.

Knut Anders

Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority.