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

JDBC unable to retrive russian characters from MS SQL server/Access2000

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.1
    • core-libs



      Name: gm110360 Date: 11/06/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4
      Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

      FULL OS VERSION :
      both Windows2000 professional and Windows2000 advanced server

      A DESCRIPTION OF THE PROBLEM :
      I was trying to retrieve russian text from Access2000 and MS SQl servers. Both these support unicode compression. When I read the data using standars Jdbc:Odbc drivers, all characters were appearing as "????" only. I tried java.nio.charsets package, then getbinaryStream(), getCharStream(), getBytes(), getUnicodeStream() of Resultset but they appeared to return ascii only. Finally I downloaded another driver from sourceforge ( http://databases.foundries.sourceforge.net/databases/03/04/03/1422211.shtml?tid=49 ) and everything worked well. I am retriving japanese also without pain. I think the problm was with sun Jdbc drivers

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      everything given in above description

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      unicode data was to be retrived
      ACTUAL -
      "???????????" only (perhaps this is ascii)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      ///everything usual as a normal database connection

      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection con = DriverManager.getConnection("jdbc:odbc:mydb",uid,pwd)
      String sql = "SELECT cast(russian as nvarchar) COLLATE Cyrillic_General_CI_AS as russian from language_tbl";

      while (rs.next())
      {
      String str = rs.getString("russian");
      Charset cset = Charset.forName("UTF8");

      CharsetDecoder cd=cset.newDecoder();

      ByteBuffer bbuf = ByteBuffer.wrap(str.getBytes("UTF8"));
      CharBuffer cbuf = cd.decode(bbuf);
      StringBuffer strBuf = new StringBuffer();

      while(cbuf.hasRemaining()) {
      strBuf.append((char)cbuf.get());
      }

      System.out.println("strBuf="+strBuf); // may not print properly in console..so write to any filestream
             myOutStream.write(strbuf.toString());

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      nothing..wait for fixes or look for another driver
      (http://databases.foundries.sourceforge.net/databases/03/04/03/1422211.shtml?tid=49 )
      (Incident Review ID: 186686)
      ======================================================================

            jbrucesunw Jonathan Bruce (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: