4302836 4302836 - 1 year ago 80
Java Question

set maximum 3 digit decimal value in in database

I want to store the data in maximum three digit after decimal point in data base using hibernate
My Value Storing in db having

column property double 124323.76754287

while I want to store

If possible Please help me.

Answer Source

Play with a table design and test overflow possibilities.

create table numTests
(   id int auto_increment primary key,
    d2 decimal(10,2) not null,
    d3 decimal(10,3) not null,
    myF float not null,
    myD double not null
insert numTests(d2,d3,myF,myD) values
(122.226,122.226,122.2223333,333.44444444); -- decimal place truncate on d2

insert numTests(d2,d3,myF,myD) values
(122.12,122.226,122.2223333,333.44444444); -- no truncate

MySQL Manual Pages entitled Numeric Types and Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC

It would appear that you want to shoot for DECIMAL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download