This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 166929 - can not store correct value for DECIMAL
Summary: can not store correct value for DECIMAL
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jiri Rechtacek
URL: http://d.hatena.ne.jp/shin/20090612/p1
Keywords: NETFIX
Depends on:
Blocks:
 
Reported: 2009-06-11 17:09 UTC by Masaki Katakai
Modified: 2012-05-29 05:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki Katakai 2009-06-11 17:09:39 UTC
It looks dataview is using double for DECIMAL now. It causes a problem that
it can not store exact value over 16 digit.

org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java:

                case Types.DECIMAL:
                    numberObj = (valueObj instanceof Number) ? (Number) valueObj : new BigDecimal(valueObj.toString());
                    ps.setDouble(index, numberObj.doubleValue());
                    break;

The above codes should be following. Another point is, it's better to
use Long for BIGINT.

                case Types.BIGINT:
                    numberObj = (valueObj instanceof Number) ? (Number) valueObj : new Long(valueObj.toString());
                    ps.setLong(index, numberObj.doubleValue());
                    break;

                case Types.DECIMAL:
                case Types.NUMERIC:
                    BigDecimal bigDec = new BigDecimal(valueObj.toString());
                    ps.setBigDecimal(index, bigDec);
                    break;

This issue has been reported from community user in Japan.
Comment 1 Jiri Rechtacek 2009-06-12 09:10:57 UTC
Masaki, please don't use P2 as default priority for each new report. Consider and justify why you realized it as P2. I
don't see it as P2 at all. It's one of many problems in DB module, nothing more.
Moreover, the code you mentioned in the report is in NB65 sources too. No regression in this code.
Comment 2 Masaki Katakai 2009-06-12 10:11:32 UTC
Hi Jiri,

I see. Thank you for the evaluation.
Comment 3 Jaroslav Havlin 2012-05-28 14:36:35 UTC
http://hg.netbeans.org/core-main/rev/c39811a65709
Thank you for providing the fix.
Comment 4 Quality Engineering 2012-05-29 05:37:37 UTC
Integrated into 'main-golden', will be available in build *201205290002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c39811a65709
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #166929: Can not store correct value for DECIMAL