db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-2073) Inserting BigDecimal value in PreparedStatement into double column loses fractional digits
Date Sun, 14 Oct 2007 19:07:50 GMT

    [ https://issues.apache.org/jira/browse/DERBY-2073?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12534657
] 

Knut Anders Hatlen commented on DERBY-2073:
-------------------------------------------

Hmm, seems like the client driver isn't too fond of negative scales... With 10.3, I see that
this piece of code fails with ClientDriver:

        PreparedStatement ps = c.prepareStatement("values cast(? as double)");
        BigDecimal bd = new BigDecimal(3000).setScale(-1);
        ps.setObject(1, bd, Types.DECIMAL, -1);

Exception in thread "main" java.sql.SQLException: '-1' is an invalid scale.
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:96)
        at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:362)
        at org.apache.derby.client.am.PreparedStatement.setObject(PreparedStatement.java:1483)
        at bigdec.main(bigdec.java:10)
Caused by: org.apache.derby.client.am.SqlException: '-1' is an invalid scale.
        at org.apache.derby.client.am.PreparedStatement.checkForValidScale(PreparedStatement.java:2433)
        at org.apache.derby.client.am.PreparedStatement.setObjectX(PreparedStatement.java:1492)
        at org.apache.derby.client.am.PreparedStatement.setObject(PreparedStatement.java:1478)
        ... 1 more

The same code runs just fine on EmbeddedDriver. Perhaps something for a new JIRA?

> Inserting BigDecimal value in PreparedStatement into double column loses fractional digits
> ------------------------------------------------------------------------------------------
>
>                 Key: DERBY-2073
>                 URL: https://issues.apache.org/jira/browse/DERBY-2073
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.1.2.1
>         Environment: windows xp
>            Reporter: Lukasz P
>            Assignee: Kathey Marsden
>         Attachments: BigDecimalProblemTester.java, NegativeScaleTest.java
>
>
> Create table with column of type double.
> Create a prepared statement which inserts value to this column.
> use preparedStatement#setBigDecimal method of the statement to set value of the column.
> Execution of such statement succeeds, but actual value in db has no fractional digits.
> You can use attached test class to reproduce this problem

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message