You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by maomaode <ma...@gmail.com> on 2007/09/17 09:19:03 UTC

Ibatis and charset

Hi,

I'm using Ibatis 2.1.7.597

mysql-connector-java 5.0.5
mysql V 5.0.45
JDK 1.6


I'm using the following script to create the database

 > create database mydb default charset utf8 COLLATE utf8_general_ci;

I have set the following config in the my.ini

 > my.ini
 > [mysqld]
 > default-character-set=UTF8


And the mysql connection url is like the following;

 > jdbc:mysql://localhost/mydb?useUnicode=true&characterEncoding=UTF8


But if I insert the Chinese char into the table, i still got the junk 
characters.

Anyone have solutions to this?


Thanks in advance,
James



Re: Ibatis and charset

Posted by Graeme J Sweeney <ib...@gjsweeney.com>.
On Tue, 18 Sep 2007, maomaode wrote:

> JDK6 + Mysql-Conn-3.0.10 + Mysql 5.0.45  + GBK (or GB2312, not the utf8)

AIUI all your Unicode will be converted to GBK, yet your inserts now 
seem to work (server-side conversion?).

> My Chinese characters is in UTF-8 (load from xml file, and encoded with 
> utf-8), and platform as well.

You could try calling "SET NAMES utf8".

-- 
Graeme -

Re: Ibatis and charset

Posted by maomaode <ma...@gmail.com>.
Graeme J Sweeney wrote:
> On Mon, 17 Sep 2007, maomaode wrote:
>
>> But if I insert the Chinese char into the table, i still got the junk 
>> characters.
>>
>> Anyone have solutions to this?
>
> jdbc:mysql://localhost/mydb?characterEncoding=utf8
>
> Your Chinese characters must be utf-8 and your viewing platform must 
> be utf-8 enabled too.
>


Thanks for the reply, you mean that the utf8 MUST lower cased? and the 
"useUnicode=true" is not required.

I tried this way, but still not working.

I tried couple version combination. but only this one works:


JDK6 + Mysql-Conn-3.0.10 + Mysql 5.0.45  + GBK (or GB2312, not the utf8)

All the version of Mysql-conn greater than 3.0.10, is not working.

Am I miss something?

My Chinese characters is in UTF-8 (load from xml file, and encoded with 
utf-8), and platform as well.

Strange?

James

Re: Ibatis and charset

Posted by Graeme J Sweeney <ib...@gjsweeney.com>.
On Mon, 17 Sep 2007, maomaode wrote:

> But if I insert the Chinese char into the table, i still got the junk 
> characters.
>
> Anyone have solutions to this?

jdbc:mysql://localhost/mydb?characterEncoding=utf8

Your Chinese characters must be utf-8 and your viewing platform must be 
utf-8 enabled too.

-- 
Graeme -