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

The java.sql.Numeric(String s) constructor works wrong

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 1.0.2
    • Fix Version/s: 1.1
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: saf@russia Date: 09/04/96


      This bug was found by St.Petersburg Java SQE team (by Mikhail Gorshenev).

      The java.sql.Numeric(String s) constructor works wrong
      if s contains two decimal points or a sign between digits

      The java.sql specification (JDBC version 1.01) says the following:
      "public Numeric(String s)
         Creates a numeric from a string.
         The string may contain a sign and a decimal point, e.g "-55.12".
         Spaces and other non-numeric characters are ignored.
         Scientific notation, i.e. mantissa with exponent (3E.05) is supported.
         Parameters:
               s - the string used to initialize the Numeric.
      "


      Here is the minimized test demonstrating the bug:

      ----- java_sql_Numeric_Ctor1.java ---------------------------------------
      import java.sql.Numeric;
      class java_sql_Numeric_Ctor1 {
        public static void main(String argv[]) {
            Numeric n1 = new Numeric("1-2");
                               // will print "-12" instead of "12"
            System.out.println("Numeric(\\"1-2\\") = " + n1);
            Numeric n2 = new Numeric("1.2.3");
                               // will print "12.3" instead of "1.23" (?)
            System.out.println("Numeric(\\"1.2.3\\") = " + n2);
        }
      }

      ----- The output of the test: -------------------------
      Numeric("1-2") = -12
      Numeric("1.2.3") = 12.3
      -------------------------------------------------------


      Workaround:
      None
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mhapnersunw Mark Hapner (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: