Java Unicode <-> MySQL Unicode
Posted by: Dmitry Katsubo
Date: April 04, 2006 02:51AM

Hello all!

What is correct representation of latin1 'u umlaut' latter? I've reffered the following documents:


It is said, that 'u umlaut' corresponds to 0x00FC. But MySQL stores it as 0xC3BC as well as any UTF8-aware text editor :(
As the result, when I am trying to use Connector-J v3.1.12 I fail to see the unicode chars, as MySQL knows them, rather I see 0x00FC. As the result, cyrillic chars are treated incorrectly at all. As I've seen in mysql-connector-java-3.1.12 sources, the driver does not issue 'use names utf8' at the init stage, but rather relies on 'character_set_server' variable. I can't set this variable to utf8, as soon as I have different databases, running different encodings in MySQL server and this setting breaks the normal behaviour. Why not using 'character_set_database' ?

Thanks a lot in advance.

Importand datasource options are:

<connection-property name="useUnicode">true</connection-property>
<!-- Has no effect: -->
<!-- connection-property name="characterEncoding">UTF-8</connection-property -->

The corresponding Java code is:

String name = ...;
PreparedStatement st = ...;

st.setBytes(1, name.getBytes("UTF-8"));
//st.setString(1, name) -- has the same effect

Options: ReplyQuote

Written By
Java Unicode <-> MySQL Unicode
April 04, 2006 02:51AM

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.