Query MySql database with chinese characters?
Date: June 16, 2008 09:20AM
I am using a java project to write and read a MySql database containing both Chinese characters and numbers. The database uses charset utf8 and Chinese characters are written into it perfectly. But when I try to use a query with a Chinese query condition such as:
SELECT froumID FROM forums WHERE forumName='"[Chinese characters]";
It returns empty set, although there are items satisfying the condition.
In command line client, if I "set names utf8" and use the query above again, it still returns empty set. However if I changed to "set names gb2312" (the gb2312 is the default Chinese charset), and use that query again, it succeeds. But I can't use "set names gb2312" in the java project, because if I do that, it reports an error as
Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gb2312_chinese_ci,COERCIBLE) for operation '='
Can anyone tell me what's wrong?
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.