db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Re: PreparedStatement setObject() and SMALLINT
Date Wed, 18 Jan 2006 06:58:56 GMT
Hi Tony,

When you use setShort, the signature of the method is void
setShort(int parameterIndex, *short* x)

But when you use void setObject(int
you are passing an instance of java type *Short *which is not one of the
acceptable Java Types for JDBC type SMALLINT (JDBC 3.0 specification has a
data type conversion section. In that section, it shows BigDecimal, Boolean,
Integer, Long, Float, and Double as the acceptable java types for JDBC
SMALLINT.) So, I think what you are running into is Derby behavior as per
the JDBC specification,


On 1/17/06, Tony Seebregts <tonys@cibecs.com> wrote:
> Hi,
> Not sure if this is a bug or intentional, but invoking setObject
> (parameter,value) where the column is a SMALLINT and the value is a
> Short throws the following exception:
> SQL Exception: An attempt was made to get a data value of type
> 'SMALLINT' from a data value of type 'java.lang.Short'.
> Invoking setShort(..) on the same column works just fine.
> regards
> Tony Seebregts

View raw message