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:
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
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://
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