RE: Translated characters stored in database

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello,

The fix can be obtained by calling our support and referencing this
Knowledge Base article:
FIX: Some parameter values that are sent in a non-Unicode format may be
incorrectly converted when you use the SQL Server 2000 Driver for JDBC
http://support.microsoft.com/?kbid=910369

There was also a subsequent bug that you might be running into:

Unicode data is translated incorrectly when you use JDBC to try to retrieve
the data by using an updatable recordset
http://support.microsoft.com/?kbid=910314

I would recommend that you obtain the second version since that will
contain both fixes.

Thanks,
Kamil

Kamil Sykora [MSFT]
Microsoft Developer Support - Webdata

This posting is provided "AS IS", with no warranties, and confers no
rights.

Please do not send email directly to this alias. This alias is for
newsgroup
purposes only.
--------------------
| From: =?Utf-8?B?YW5pdGhh?= <anitha@xxxxxxxxxxxxxxxxxxxxxxxxx>
| Subject: RE: Translated characters stored in database
| Date: Fri, 5 May 2006 18:13:01 -0700
|
| Hi,
|
| Can you please give the update on the solution. Is a new version of the
| driver available now? I am facing a similar problem now.
|
| Thanks in advance
| Anitha
|
| "BirchBarlow" wrote:
|
| > Kamil & MSFT:
| >
| > Thank you for the analysis and acknowledgement of the issue. I look
forward
| > to a fix.
| >
| >
| >
| >
| > "Kamil Sykora [MSFT]" wrote:
| >
| > > I was able to reproduce the problem. Sorry about the confusion.
| > >
| > > I filed a bug on this problem.
| > >
| > > Thanks,
| > > Kamil
| > >
| > > Kamil Sykora
| > > Microsoft Developer Support - Web Data
| > >
| > > Please reply only to the newsgroups.
| > > This posting is provided "AS IS" with no warranties, and confers no
rights.
| > >
| > >
| > > Are you secure? For information about the Strategic Technology
Protection
| > > Program and to order your FREE Security Tool Kit, please visit
| > > http://www.microsoft.com/secur­ity.
| > >
| > >
| > >
| > > | From: kamils@xxxxxxxxxxxxxxxxxxxx (Kamil Sykora [MSFT])
| > > | Organization: Microsoft Developer Support
| > > | Date: Tue, 24 May 2005 16:12:13 GMT
| > > | Subject: RE: Translated characters stored in database
| > > |
| > > | Hello,
| > > |
| > > | I tested your code with this binary data in the infile.txt:
| > > |
| > > | 20 21 22 23 24 25 26 27 28 29 30 7B 7C 7D 7E 7F 80 82 83 84 85 86
87 88
| > > 89
| > > | 8A C0 C1 C2 C3 C4 C5 F0 F1 F2 F3 FE FF
| > > |
| > > | I then insert the data with the code below into the database. The
result
| > > is
| > > | below. Note that the characters are probably not displaying
correctly but
| > > | the hex values should:
| > > |
| > > | select text, cast (text as varbinary(40)) from texttable
| > > |
| > > | text

| > >
| > > |

| > >
| > > |
| > > |
| > >
----------------------------------------------------------------------------
| > > | ------------------------
| > > |
| > >
----------------------------------------------------------------------------
| > > | ------
| > > | !"#$%&'()0{|}~â?¬â??Æ?â??â?¦â? â?¡Ë?â?°Å Ã?Ã?Ã?Ã?Ã?Ã?ðñòóþÿ

| > >
| > > |
| > > |
| > >
0x20212223242526272829307B7C7D7E7F8082838485868788898AC0C1C2C3C4C5F0F1F2F3FE
| > > | FF
| > > |
| > > |
| > > | This is what I would expect. Are you seeing different results? If
so,
| > > what
| > > | data are you seeing?
| > > |
| > > | Thanks,
| > > | Kamil
| > > |
| > > | Kamil Sykora
| > > | Microsoft Developer Support - Web Data
| > > |
| > > | Please reply only to the newsgroups.
| > > | This posting is provided "AS IS" with no warranties, and confers no
| > > rights.
| > > |
| > > |
| > > | Are you secure? For information about the Strategic Technology
| > > Protection
| > > | Program and to order your FREE Security Tool Kit, please visit
| > > | http://www.microsoft.com/secur­ity.
| > > |
| > > |
| > > |
| > > | --------------------
| > > | | From: "=?Utf-8?B?QmlyY2hCYXJsb3c=?="
| > > | <BirchBarlow@xxxxxxxxxxxxxxxxxxxxxxxxx>
| > > | | Subject: Translated characters stored in database
| > > | | Date: Sun, 22 May 2005 21:26:07 -0700
| > > | | Lines: 43
| > > | |
| > > | | Is this a known issue? I am using the MS JDBC driver to connect
to SQL
| > > | | Server 2000 SP3a. The driver version is either SP2 or SP3. I
tested
| > > | both
| > > | | with the same results. The database collation is Latin1. Sun
java
| > > 1.3.1
| > > | or
| > > | | 1.4.2. When using the SendStringParametersAsUnicode=false in the
| > > | connection
| > > | | string the driver translates the characters in the 0x80 to 0x9f
range.
| > > | The
| > > | | translation does not occur when setting the above connection
parameter
| > > to
| > > | | true. I have also tested the Data Direct driver and there is no
| > > | character
| > > | | translation with the parameter true or false. I have enclosed a
sample
| > > | piece
| > > | | of code to illustrate the issue. I need to use the parameter as
false
| > > | since
| > > | | there is a significant performance hit with it set to true. Also
my
| > > | | application requires support for the full Latin1 (Windows 1252)
| > > character
| > > | | set. It looks like the character translation is a result of
dropping
| > > the
| > > | | upper byte of the Unicode character which for all characters
except
| > > 0x80
| > > | -
| > > | | 0x9f is 0x00. If you look at the Windows 1252 character set
Unicode
| > > | values
| > > | | you will see that the 0x80 to 0x9f characters have a value in the
upper
| > > | byte
| > > | | therefore simply truncating the upper byte produces a character
| > > | translation.
| > > | | Example: Character 0x80 has the Uniccode value of 0x20AC and is
| > > | translated to
| > > | | 0xAC in the database.
| > > | |
| > > | | table1:
| > > | | varchar(300);
| > > | |
| > > | | file: infile.txt is a binary file with the characters bytes 0x20
to 0xff
| > > | |
| > > | | Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
| > > | | con =
| > > | |
| > > |
| > >
DriverManager.getConnection("jdbc:microsoft:sqlserver://myserver;SelectMetho
| > > |
| > >
d=cursor;SendStringParametersAsUnicode=false;user=test;password=test;Databas
| > > | eName=TestDB"
| > > | | );
| > > | |
| > > | | BufferedReader r = new BufferedReader(new
FileReader("infile.txt"));
| > > | | String text = r.readLine();
| > > | |
| > > | | PreparedStatement pstmt = null;
| > > | | String sqlQuery = "insert into table1 (text) values (?)";
| > > | |
| > > | | pstmt = con.prepareStatement(sqlQuery);
| > > | | pstmt.setString(1, text);
| > > | | pstmt.execute();
| > > | |
| > > | | pstmt.close();
| > > | | pstmt=null;
| > > | | con.close();
| > > | | con=null;
| > > | |
| > > |
| > > |
| > >
| > >
|

.



Relevant Pages

  • RE: Translated characters stored in database
    ... FIX: Some parameter values that are sent in a non-Unicode format may be ... Kamil Sykora [MSFT] ... Microsoft Developer Support - Webdata ... Please do not send email directly to this alias. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: OWA Error 2147023570
    ... >The fix is not posted on our site. ... >Microsoft Exchange Support ... >Please do not send email directly to this alias. ... >> confers no rights. ...
    (microsoft.public.exchange.clients)
  • Re: The Information Store service and Outlook 2003 crash intermittently when Outlook
    ... Call Microsoft Support to get the hotfix. ... If you just want the fix and do ... Please do not send email directly to this alias. ...
    (microsoft.public.exchange.misc)
  • [GIT]: Networking
    ... Make VLAN and MACVLAN drivers support multiqueue, ... Return type of net driver xmit routines is formalized into ... Lots of bluetooth fixes and cleanups from Marcel Holtmann ... Fix premature termination of FIN_WAIT2, ...
    (Linux-Kernel)
  • [GIT]: Networking
    ... maintainer making a lot of changes to driver FOO. ... support for networking. ... iwl3945: Fix iwl3945 rate scaling. ... Fix build warning due to typo in %pI4 format changes. ...
    (Linux-Kernel)