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

ODBC-JDBC-Bridge unable to deal with Umlauts

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Future Project
    • Affects Version/s: 6u20
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Sybase SQL Anywhere 11.0.1

      A DESCRIPTION OF THE PROBLEM :
      There is a master-detail relationship between A and B.
      B is referencing A by a foreign key.
      Some of the existing entries are having German umlauts.
      SELECTing a key from A, not touching the result string, providing that string as a parameter to INSERT INTO B (to fulful the foreign key relationship) results in an SQL exception that such a key is not found in A and such the foreign key constraint would be violated.
      This ONLY happens with the ODBC-JDBC-Bridge contained in the JRE.
      This does NOT happend from a C++ ODBC application utilizing the same ODBC driver.
      The exact same code is working pretty well when using the native JDBC drivers (of which one actually is also a ODBC-JDBC bridge itself, using exactly the same ODBC driver).
      So it looks as if this is neither a bug in the ODBC driver but more a bug of the ODBC-JDBC-Bridge contained in the JRE.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Install free developer edition of Sybase "SQL Anywhere 11.0.1".
      Using dbinit create a database.
      Using ODBCAD32 set up an ODBC DSN for it.
      Using the native tool "dbisql" Create needed tables and foreign keys.
      Using the native tool "dbisql" insert some PKS into table A, having German umlauts.
      Compile and run the sample code included in this bug report.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Shall always print a list on the screen with Umlauts.
      ACTUAL -
      JDBC-ODBC-Bridge:

      After the first Umlauts had been printed, programm stopped with SQL Exception telling that the foreign key constrained is violated. Also, the Umlauts had been printed as question marks.

      Native JDBC drivers (including native bridge):

      Works as expected, printing umlauts as umlauts (not as question marks).

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.sql.SQLException: [Sybase][ODBC Driver][SQL Anywhere]No primary key value for foreign key 'fk_teilefamilie' in table 't_qmk'

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.Statement;

      public class UmlautsBug {
          public static void main(String[] args) throws Exception {

            // Generic ODBC-JDBC-Bridge will fail with SQLException
            final Connection c = DriverManager.getConnection("jdbc:odbc:QUIPSY 4 DBFILE");

            // Native JDBC driver will succeed.
      // Class.forName("sybase.jdbc.sqlanywhere.IDriver");
      // final Connection c = DriverManager.getConnection("jdbc:sqlanywhere:uid=DBA;pwd=sql;eng=demo;dbn=demo");

            // Native bridge will succedd.
      // Class.forName("ianywhere.ml.jdbcodbc.jdbc3.IDriver");
      // final Connection c = DriverManager.getConnection("jdbc:ianywhere:Driver=SQL Anywhere 11;ENG=demo;DBN=demo;UID=DBA;PWD=sql");

              c.setAutoCommit(false);
              final Statement s = c.createStatement();
              final ResultSet rs = s.executeQuery("SELECT a_pk FROM A");
              final PreparedStatement ps = c.prepareStatement("INSERT INTO B (b_pk, a_fk) VALUES (?,?)");
              int i = 0;
              while (rs.next()) {
                  final String a = rs.getString(1);
                  System.out.println(a); // Generic bridge prints question marks instead of umlauts
                  ps.setInt(1, i++);
                  ps.setString(2, a);
                  ps.execute(); // Generic bridge throws SQLException with umlauts in a
              }
              c.rollback();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not using generic bridge but always using driver provided by vendor.

        Attachments

          Activity

            People

            Assignee:
            lancea Lance Andersen
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: