Services Partners Company
Knowledge Base


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. 
Steps to Reproduce
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 
Disclaimer

The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.



Feedback
 
Was this article helpful?

   

Your feedback is appreciated.

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



Characters Remaining: 255