Article

SQL: JDBC driver returns zero decimal values in scientific notation

« Go Back

Information

 
EnvironmentIf the scale is less than 7 or the value is not equal to zero, the field (column) is displayed in its proper decimal format as expected.
???This issue is not reproducible under 10.1A or 10.1B that use java version "1.4.2_06". Hence, it is a regression b
Question/Problem Description
SQL: JDBC driver returns zero decimal values in scientific notation
The JDBC driver, returns the zero values in scientific notation for fields whose DECIMALS attribute is 7 or more.
When the scale, i.e. the number of digits to the right of the decimal point, of a decimal column is greater than 6 the JDBC driver returns its zero values in scientific notation. For example, it returns 0E-7 instead of 0.0000000.
The JDBC driver returns zero values in scientific notation when column scale (i.e. the number of digits to the right of the decimal point) is greater than 6.
This issue has been reproduced using the OpenEdge Architect SQL Editor, the OpenEdge SQL Explorer Tool and a stand alone Java Program. 
Clarifying Information
Error Message
Defect/Enhancement NumberOE00207707
Cause
This issue started with OpenEdge use of java version "1.5.0_11". That is in OpenEdge 10.1C and later.  It may be related to the changes to the BigDecimal toString method in JDK 1.5.
Resolution
None at this time
Workaround
Notes

To use following Bug.java code, modify the connection string to reflect your environment (Host name, Port number, Database name, User name, Password, etc.):

import java.sql.*;
import java.util.*;
import java.io.*;

public class Bug{
    public static void main(String [] args) {

        String spy = "(log=(file)spy.log;logTName=yes;timestamp=yes)";
        String url = "jdbc:datadirect:openedge://localhost:12345;databaseName=sports2000;SpyAttributes=" + spy;
        String drv = "com.ddtek.jdbc.openedge.OpenEdgeDriver";
        String usr = "yshanshi";
        String pwd = "";
        String sql = "SELECT Scale5, Scale6, Scale7, Scale8 from pub.JDBCDecimalBug";
       
        Connection con;
        Statement stmt;
        ResultSet rs;

        try {
            Class.forName(drv);
            }
        catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }

        try {
            java.io.PrintStream pStream = new java.io.PrintStream(System.out, true);
            con = DriverManager.getConnection(url,usr, pwd);
            con.setAutoCommit(false);
            stmt = con.createStatement();
            rs = stmt.executeQuery(sql);
            while (rs.next()) {
                System.out.println(rs.getString(1) + "   " + rs.getString(2) + "   " + rs.getString(3) + "   " + rs.getString(4));
            }
            stmt.close();
        }
        catch (SQLException ex) {
            System.out.println ("*** (debugging) in sql exception block...");
            while (ex != null) {
                System.out.println ("SQLState: " + ex.getSQLState ());
                System.out.println ("Message:  " + ex.getMessage ());
                System.out.println ("VendorCode:   " + ex.getErrorCode());
                ex = ex.getNextException ();
                System.out.prin.tln ("");
            }
        }
        catch (java.lang.Exception ex) {
            System.out.println ("*** (debugging) in general exception block...");
            ex.printStackTrace ();
        }
        finally {
            System.out.println ("finally...");
        }
    }
}

.tln ("");
            }
        }
        catch (java.lang.Exception ex) {
            System.out.println ("*** (debugging) in general exception block...");
            ex.printStackTrace ();
        }
        finally {
            System.out.println ("finally...");
        }
    }
}.
Attachment 
Feedback
 
Was this article helpful?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful.



Characters Remaining: 255

 



Copyright © 1993-2014. Progress Software Corporation. All Rights Reserved. See the next generation of application development and data connectivity software, try now!