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

Updatable ResultSet in jdbc-odbc wrong with national letters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.1
    • 1.3.0
    • core-libs
    • ladybird
    • x86
    • windows_nt



        Name: skT45625 Date: 05/03/2000


        java version "1.3.0rc2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc2-Y)
        Java HotSpot(TM) Client VM (build 1.3.0rc2-Y, mixed mode)

        There is a test program:

        --- Test.java

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

        public class Test
        {
         static void dump(byte[] buf)
         {
          for(int i=0; i<buf.length; i++)
            {
             int v = buf[i] & 0xff;
             System.out.print( Character.forDigit(v >> 4,16) );
             System.out.print( Character.forDigit(v & 0xf,16) );
            }

          System.out.println();
         }

         public static void main(String[] args) throws Exception
         {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

          Properties connInfo = new Properties();
          connInfo.put("charSet","Cp1251");

          Connection db = DriverManager.getConnection("jdbc:odbc:test", connInfo);

          Statement stmt = db.createStatement();

          stmt.executeUpdate("DROP TABLE Test");
          stmt.executeUpdate("CREATE TABLE Test (Val VARCHAR(10))");

          stmt.executeUpdate("INSERT INTO Test (Val) VALUES (\'\u0410\u0411\')");

          ResultSet rs = stmt.executeQuery("SELECT Val FROM Test");

          while( rs.next() )
            {
             dump( rs.getBytes(1) );
            }

          Statement rsstmt = db.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
        ResultSet.CONCUR_UPDATABLE);

          rs = rsstmt.executeQuery("SELECT Val FROM Test");

          rs.first();

          rs.updateString(1,"\u0410\u0411");
          rs.updateRow();
          rs.close();
          rsstmt.close();

          rs = stmt.executeQuery("SELECT Val FROM Test");

          while( rs.next() )
            {
             dump( rs.getBytes(1) );
            }
         }
        }
        ---

        Create new database with MS Access 97, and execute this.

        The program output:

        ---
        c0c1
        d090d091
        ---

        Similar results produced, when using another methods instead
        updateString(). For example, if replace updateString() with:

          byte[] buf = "\u0410\u0411".getBytes("Cp1251");
          rs.updateBytes(1,buf);

        then output is:

        ---
        c0c1
        00fd7600582275001100
        ---

        And, if use:

          byte[] buf = "\u0410\u0411".getBytes("Cp1251");
          rs.updateBinaryStream(1,new java.io.ByteArrayInputStream(buf),buf.length);

        then output is:

        ---
        c0c1
        1cfd7600582275001000
        ---

        Correct behavoir (in all these cases) should be:
        ---
        c0c1
        c0c1
        ---
        (Review ID: 103243)
        ======================================================================

              jellissunw Jon Ellis (Inactive)
              skondamasunw Suresh Kondamareddy (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: