Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5096664

PreparedStatement.setFloat does not enter precise values into database

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • 1.4.2
    • core-libs

    Description



      Name: js151677 Date: 09/03/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
      Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Hi
      I have written a program where I am entering a record in to the database using a prepared statement. The problem is for float datatypes, the values being entered into the database are not rounded off. e.g. 1.65 is being entered as 1.64999999
      I am using the Sybase database and the driver is com.sybase.jdbc2.jdbc.SybDriver.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use a prepared stsatement to enter a record into a database, where at least one column is a float.
      Enter a record which has a value for the float column.
      Compare the actual and the entered values.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both values should have been same
      ACTUAL -
      1.65 was coming up as 1.649999
      0.03 was coming up as 0.29999988

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Use java.sql.Statement instead of java.sql.PreparedStatement
      (Incident Review ID: 296734)
      ======================================================================

      Attachments

        Activity

          People

            ahandasunw Amit Handa (Inactive)
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: