Re: Sure: Bug with Encoding: \x80 \x81 ...
Posted by: Mark Matthews
Date: May 30, 2007 01:15PM

Bambarbia Kirkudu Wrote:
-------------------------------------------------------
> 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

That error comes from the server, not the driver.

> 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"

The driver uses CP1252 for "latin1" (the encoding on the MySQL server).

>
> 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.

Feel free to file a _repeatable_ _standalone_ bug report at http://bugs.mysql.com/

>
> P.S.
> Why are you simulating PreparedStatement instead
> of direct coding to MySQL API?

Because until recently, server prepared statements were very unstable and don't work with all MySQL server features (for example stored procedures, the query cache, etc). Even currently you can not use prepared statements for _every_ query, even though JDBC does not have this restriction.

Also, the prepared statement implementation pre-dates prepared statements being available in MySQL server by several years, since JDBC users almost exclusively use PreparedStatements.

-Mark

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

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.