Does jdbc support persian language

2019-07-11 19:28发布

I designed a java desktop application using jdbc technology to connect to mysql database. But when I want to store a data in my db which is in persian language it saved like some ????

I tried creating the database with both

CREATE DATABASE 'db' CHARACTER SET 'utf8';

and

CREATE TABLE  `Table1` (
[...]) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

I tried every other COLLATEs but they seem not working properly.

What should I do?

2条回答
虎瘦雄心在
2楼-- · 2019-07-11 19:53

Make sure the driver properties are set. Check that useUnicode is true, characterEncoding is "UTF-8". I assume you are using the Connector/J JDBC driver.

查看更多
疯言疯语
3楼-- · 2019-07-11 19:58

Refer to this answer. A brief version of what the answer says is that you should add

?useUnicode=true&characterEncoding=UTF-8

To the end of JDBC connection URL. For example:

jdbc:mysql://localhost:3306/db_name?useUnicode=yes&characterEncoding=UTF-8
查看更多
登录 后发表回答