Bug #64782 latin1 charset in java cause wrong data reading from latin1 tables

Submitted: 28 Mar 2012 3:50 Modified: 16 Apr 2012 13:51
Reporter: zhu songjie Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.18 OS:Any
Assigned to: CPU Architecture:Any
Tags: Latin1

[28 Mar 2012 3:50] zhu songjie
Description:
Description:
Server: mysql community server version 5.0.22
Connector/J : mysql java driver  5.1.18
JDK : Oracle JRockit 1.6.0_29-b11 and Sun Java 1.6.0_22-b04

How to repeat:
we create table using charset latin1 and create a varchar column, using it to store raw
bytes in latin1 string, we use this method to store multi-bytes string in the past on
mysql server 5.0.22 versions.

but we can't get 
the right bytes from the server with connect parameter characterEncoding=latin1.
use jdbc jdbc:mysql://172.16.103.176:3306/mondb?useUnicode=true&characterEncoding=latin1
for example:
we store a multi-bytes string in the latin1 varchar column
the chinese chars   : '财务'

when we query from java, it looks strange.
if we use ResultSet.getBytes(), it will get the right bytes.
but if we use ResultSet.getString(), it will give me wrong string like:'2???'

so i search in google how to resolve this problem
but i don't find it
Looking forward to your reply

Suggested fix:
i can read correct char use driver:mm-mysql-2.0.7
wish 5.1.18 can do like it
[16 Apr 2012 13:51] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

You can not use ResultSet.getString() if raw bytes are stored. Please use way to store multi-byte characters introduced in MySQL server of version 4.1

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.