[ 
http://issues.apache.org/jira/browse/DERBY-1500?page=comments#action_12424621 ] 
            
Daniel John Debrunner commented on DERBY-1500:
----------------------------------------------

Markus wrote:
 "Also, why does stmnt.setShort(1, Short.valueOf("0")) work in this case? "

Because that's part of the JDBC api, convert a Java primitive short to a 
SMALLINT value and send it to the database.

What you are asking for is a non-standard extension to JDBC, accepting 
java.lang.Short values to be valid input for setObject,
that's against the Derby charter. Much the same as it would be non-standard to 
accept  java.util.Date for a DATE column.




> PreparedStatement#setObject(int parameterIndex, Object x) throws SQL 
> Exception when binding Short value in embedded mode
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1500
>                 URL: http://issues.apache.org/jira/browse/DERBY-1500
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.1.1.0, 10.1.3.1
>         Environment: WindowsXP
>            Reporter: Markus Fuchs
>         Attachments: ShortTest.java
>
>
> When trying to insert a row into the table 
> SHORT_TEST( ID int, SHORT_VAL smallint)
> an exception is thrown, if the object value given to 
> PreparedStatement#setObject(int parameterIndex, Object x) is of type Short. 
> The exception thrown is:
> --- SQLException ---
> SQLState:  22005
> Message:  An attempt was made to get a data value of type 'SMALLINT' from a 
> data value of type 'java.lang.Short'.
> ErrorCode:  20000
> SQL Exception: An attempt was made to get a data value of type 'SMALLINT' 
> from a data value of type 'java.lang.Short'.
>       at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown 
> Source)
>       at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.dataTypeConversion(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setObject(Unknown 
> Source)
> Tested on Derby 10.1.1.0 and 10.1.3.1. The same test runs fine in network 
> mode.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to