java - Oracle JDBC: underflow in double -
when trying insert doubles double precision column of oracle table, exception when double out of range (in case: small), when using preparedstatement (if use normal statement, rounds double 0).
table:
create table test ( value double precision ); java code:
double d = 1e-234; // using statement works, number gets rounded , 0 inserted try (statement stmt = conn.createstatement()) { stmt.executeupdate("insert test values (" + d + ")"); } // using preparedstatement fails, throws illegalargumentexception: underflow try (preparedstatement stmt = conn.preparestatement("insert test values (?)")) { stmt.setdouble(1, d); stmt.executeupdate(); } - do have check , round doubles before using them in insert/update statements?
- can somehow have values automatically rounded?
thanks insights/hints.
double precision = float(126) noted in comment.
use binary_double data type have same precision java double.
reference:
Comments
Post a Comment