IBM Support

JR30238: New property decimalSeparator for the JCC driver to specify the decimal separator.

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • This APAR introduces a property for the
    Common IBM Data Server Driver for JDBC and SQLJ
    (Java Common Client, or JCC driver)
    to specify what the decimal separator should be.
    Decimal separator means the character which
    separates the whole number from the fractional part of a decimal
    number.
    The new JCC driver property is called decimalSeparator.
    
    If you do not set the JCC driver property decimalSeparator then
    the getString() method of the ResultSet class returns a
    number representation in which the decimal separator is a
    period ("."), even if the decimal
    separator should be a comma (",")
    according to the conventions of the locale of the program,
    .
    This differs from the DB2 JDBC Type 2 Driver (App driver) of
    earlier DB2 releases, for which the getString()
    method of ResultSet might return a number representation in
    which
    the decimal separator is a comma (",") if that is according to
    the conventions of the locale of the program.
    
    The possible values of decimalSeparator are
    com.ibm.db2.jcc.DB2BaseDataSource.DECIMAL_SEPARATOR_PERIOD
    (1) and
    com.ibm.db2.jcc.DB2BaseDataSource.DECIMAL_SEPARATOR_COMMA (2).
    They are defined as int.
    
    If you do not set decimalSeparator, or if you set
    decimalSeparator to
    com.ibm.db2.jcc.DB2BaseDataSource.DECIMAL_SEPARATOR_PERIOD,
    then the getString() method of ResultSet returns a
    number representation in which the
    decimal separator is a period (".").
    If you set decimalSeparator to
    com.ibm.db2.jcc.DB2BaseDataSource.DECIMAL_SEPARATOR_COMMA,
    then the getString() method of ResultSet returns a number
    representation
    in which the decimal separarator is a comma (",").
    
    
    Here is an example code fragment:
    
      <code>
      ResultSet rs;
      [...]
      if(rs.next()) {
        System.out.println(rs.getString("DECCOL"));
      }
      </code>
    
    
    
    Suppose that DECCOL is the name of a column of data type
    DECIMAL,
    and in the row returned by next() that column has a value of
    1234.56. Then, unless you set the JCC property decimalSeparator,
    the above
    code fragment outputs:
    
    1234.56
    
    even if for the locale of the program the number would normally
    be
    represented as
    
    1234,56
    
    
    If you set decimalSeparator to
    com.ibm.db2.jcc.DB2BaseDataSource.DECIMAL_SEPARATOR_COMMA
    then, provided you do not set the JCC driver property
    sendDataAsIs=true,
    you can use the a number representation with a
    comma as decimal separator for strings passed to the setString()
    method of PreparedStatement.
    
    For example, you can do this:
    
      <code>
      java.sql.PreparedStatement ps1 = con.prepareStatement ("INSERT
       INTO TESTTABLE1 ( DECCOL ) VALUES ( ? )");
      ps1.setString(1, "1234,56");
      </code>
    
    The JCC property decimalSeparator affects all SQL data types for
    which the number representation
    includes a decimal separator, including DECIMAL, DECFLOAT, REAL,
    and DOUBLE.
    

Local fix

  • The following example code fragment outputs a number
    representation with the
    decimal separator that is appropriate for the locale of the
    program:
    
     <code>
     import java.text.NumberFormat;
     import java.util.Locale;
     [...]
     ResultSet rs;
     [...]
     if(rs.next()) {
       NumberFormat f =
        NumberFormat.getInstance(Locale.getDefault());
       java.math.BigDecimal dec = rs.getBigDecimal("DECCOL");
       System.out.println(f.format(dec));
     }
     </code>
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * Users of the IBM Data Server Driver for JDBC and SQLJ (also  *
    * called the JCC driver)                                       *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * .                                                            *
    ****************************************************************
    

Problem conclusion

  • Problem was first fixed in Version 9.5 Fix Pack 5
    

Temporary fix

  • The following example code fragment outputs a number
    representation with the decimal separator that is appropriate
    for the locale of the program:
    
    <code>
    import java.text.NumberFormat;
    import java.util.Locale;
    [...]
    ResultSet rs;
    [...]
    if(rs.next()) {
      NumberFormat f =
        NumberFormat.getInstance(Locale.getDefault());
      java.math.BigDecimal dec = rs.getBigDecimal("DECCOL");
    
      System.out.println(f.format(dec));
    }
    </code>
    

Comments

APAR Information

  • APAR number

    JR30238

  • Reported component name

    DB2 UDB WSE WIN

  • Reported component ID

    5765F3501

  • Reported release

    950

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2008-08-16

  • Closed date

    2011-01-24

  • Last modified date

    2011-01-26

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    DB2 UDB WSE WIN

  • Fixed component ID

    5765F3501

Applicable component levels

  • R950 PSN

       UP

[{"Business Unit":{"code":"BU053","label":"Cloud \u0026 Data Platform"},"Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"950","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
12 October 2021