Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4335564
Votes 5
Synopsis Updatable ResultSet in jdbc-odbc wrong with national letters
Category jdbc:jdbc_odbc_bridge
Reported Against kestrel-rc2
Release Fixed 1.3.1(ladybird), 1.4(merlin-beta) (Bug ID:2033903)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 04-MAY-2000
Description




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) 
======================================================================
Work Around




The only workaround - is using INSERT and UPDATE statements
======================================================================
Evaluation
Sent to Merant.

  xxxxx@xxxxx   2000-05-03
Comments
  
  Include a link with my name & email   

Submitted On 29-MAY-2001
richiegr
This is not fixed I've hebrew char in DB, then it's 
impossible for me to use TYPE_SCROLL_INSENSITIVE cause the 
char return by getString are wrong,
the workaround is to return JDBC 1.0 !?!?!?!?
if you have any answers thanks


Submitted On 28-JUN-2001
Hedin
Hello Sun!
I was believed that evething is fixed, until today i run 
some tests.
The bug is NOT fixed.
It's still exist in ladybird (JDK 1.3.1 build 24) and in 
merlin-beta (JDK 1.4.0-beta-b65).


Submitted On 12-JUL-2001
abnormal
It's not fixed in ladybird so I will create a new bug 
report.


Submitted On 19-JUL-2001
Hedin
It's seems to already resubmited. See bug 4476228


Submitted On 14-AUG-2001
Hedin
Finally resubmit - vote for bug 4486195.



PLEASE NOTE: JDK6 is formerly known as Project Mustang