Real data type: Java mapping

  • Hi,

    I have a Java application which receives some data as IEEE 754 single precison (4 byte) values. The application converts these into java Float and stores them in a database. I read the following links and concluded that the database column storing these values should be of type REAL:

    http://download.oracle.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html

    http://msdn.microsoft.com/en-us/library/ms378878.aspx

    However, I'm now realizing that though the documentation says that Java float should be mapped to REAL, not all valid Java float values can be stored in SQL Server REAL. For example if I try to store java.lang.Float.MIN_VALUE in a real column, the database complains because apparently, the ranges of Java Float and SQL Server REAL are different.

    Interestingly, though, I'm able to store java.lang.Double.MIN_VALUE (4.9E-324) in a FLOAT(53) column even though it does not fall in the range of FLOAT(- 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 as per documentation)

    My application receives many such values in different columns. Wondering if my only option now is to change the database columns to FLOAT while keeping the Java object types as Float.

  • This was removed by the editor as SPAM

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply