Sure: Bug with Encoding: \x80 \x81 ...
Posted by: Bambarbia Kirkudu
Date: May 29, 2007 08:09PM

I finally believe there is a bug in JDBC, especially after seeing that it can't deal properly with prepared statements:

java.sql.SQLException: Incorrect string value: '\xF4\x80\x81\xB1/-...' for column 'text' at row 1

How it happens? Easy. I have a bytearray. I convert it to a Java String using windows-1252, new String(byte[], "windows-1252"). Windows-1252 is unapproved superset of ISO-8859-1. "it's better to treat ISO-8859-1 as synonymous with windows-1252 than to reject, as invalid, documents labelled as ISO-8859-1 that have characters outside ISO-8859-1"

Byte array probably has character \x80 which is control character in ISO. Even if it has... It is 'euro sign' in Windows 1252. Java String should create 'euro sign' in Unicode; JDBC should send it 'as is' to MySQL (am I right?) and 'as is' in this case should not contain \x80 because Euro Sign has different code in Unicode!!!

So, for sure, it is a bug in JDBC. JDBC does some character conversion, and MySQL utf-8 is not the same as Java String.

Why are you simulating PreparedStatement instead of direct coding to MySQL API?

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

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.