JDK-4106306 : jdbc-odbc Bridge Chinese(Big5) Bugs
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql:bridge
  • Affected Version: 1.1.1,1.2.0,1.2.1,1.2.2,1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    generic,solaris_2.5.1,windows_95,windows_98,windows_nt generic,solaris_2.5.1,windows_95,windows_98,windows_nt
  • CPU: generic,x86,sparc
  • Submitted: 1998-01-23
  • Updated: 1999-11-23
  • Resolved: 1999-11-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 kestrelFixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Description

Name: rm29839			Date: 01/23/98


In JDK 1.1.5(JDBC-ODBC 1.1001), I can not correctly display the Chinese strings queried from the Access database. 
The Chinese strings I got seemed not Big5 Code, although they are Big5 code in database.
Furthermore, I can not insert Chinese string to database.

In JDK 1.2beta2 (JDBC-ODBC 1.2001), luckily, I can queried the Chinese string from database and display it.
However, I can not insert or update the table with more than one column have Chinese string values.

You can test it just use the simpleselect.java program.
(Review ID: 23881)
======================================================================

Name: krT82822			Date: 10/14/99


10/14/99 eval1127@eng -- committed to be fixed in (final) kestrel, based on bug #'s 4106306, 4106617, as well.

This report is equal to Bug ID 4053824.

The reason JDBC-ODBC bridge can't pass DBCS string is that
sun.jdbc.odbc.JdbcOdbcObject#CharsToBytes() calls
 "nextCharIndex()" method instead of
      ^^^^
 "nextByteIndex()" method of sun.io.CharToByteConverter class.
      ^^^^

You should correct CharsToBytes() method like follow.

========================================
//concat converted array onto return array
// byte[] tRetBytes=new byte[retBytes.length + toBytes.nextCharIndex()];
byte[] tRetBytes=new byte[retBytes.length + toBytes.nextByteIndex()];
System.arraycopy(retBytes, 0, tRetBytes, 0, retBytes.length);
//System.arraycopy(outBuf, 0, tRetBytes, retBytes.length, toBytes.nextCharIndex());
System.arraycopy(outBuf, 0, tRetBytes, retBytes.length, toBytes.nextByteIndex());
retBytes=new byte [tRetBytes.length];
System.arraycopy(tRetBytes, 0, retBytes, 0, tRetBytes.length);
========================================

This is VERY IMPORTANT BUG for Japanese developer!!
So please correct rapidly!!
(Review ID: 96533)
======================================================================

Name: krT82822			Date: 11/02/99


java version "1.2"
Classic VM (build JDK-1.2-V, native threads)

Jdbc-odbc driver can't transefer Chinese char. query string, eg:
    ...
    String url = "jdbc:odbc:map263";
    try{
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection c = DriverManager.getConnection(url, "sa", "");
        Statement stmt = c.createStatement();
        String sqlstr = "select id, roadname, class from road where roadname
like '??????%'";
        ResultSet rs = stmt.executeQuery(sqlstr);
        if(rs != null)
        {
            System.out.println(sqlstr + " Conneted.");
        }
	        
        stmt.close();
        c.close();
    }catch(Exception e){
	e.printStackTrace();
   }

When I run this code, it will be report:
{{
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]
Unclosed quote before the character string '??????'.
}}
When the Chinese string more than 1 char(One Char is ok).
(Review ID: 97261)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel FIXED IN: kestrel INTEGRATED IN: kestrel
14-06-2004

WORK AROUND Name: krT82822 Date: 11/02/99 Use the following query string will be ok: "select id, roadname, class from road where roadname = 'X'"; "select id, roadname, class from road where roadname = 'XX''"; "select id, roadname, class from road where roadname = 'XXX'''"; which X represents a Chinese char. that is one more Chinese char., one more left quotation ' should be append. (Review ID: 97261) ======================================================================
11-06-2004

EVALUATION Sent to Merant 8/16/99 jon.ellis@Eng 1999-08-16 This turned out to be a bug in JdbcObject.charsToBytes() where the index into the array of chars was being used while copying the bytes. jon.ellis@Eng 1999-11-23
16-08-1999