Mysql4.1's Java Chinese problem solved

xiaoxiao2021-03-06  27

After installing a mysql4.1, there turned out Chinese issues. Hey, I haven't been troubled by Chinese problems for a long time, but I didn't expect this to toss for more than an hour.

It is necessary to say that your drive needs to be updated to mysql-connector-java-

3.0.16

Or the above version, otherwise mysql4.1 is not supported.

JDBC URL: "JDBC: mysql: // jf: 3306 / Learning? Useunicode = true & characterencoding = GBK" Explains that there is no problem in Chinese version 4.0, but there is no role in 4.1, Chinese still garbled.

Just started to use GBK, then replace it into a UTF-8 test, the result is not. Check the http://dev.mysql.com/doc/connector/j/en/index.html document, found that the cashman:

Using the UTF-8 Character Encoding - Prior to MySQL server version 4.1, the UTF-8 character encoding was not supported by the server, however the JDBC driver could use it, allowing storage of multiple character sets in latin1 tables on the server.

Check the http://dev.mysql.com/doc/connector/j/en/cj-character-sets.html document, found that Latin1 default is the character encoding of ISO8859_1.

However, it is also invalid from ISO8859_1 to GBK from the database.

Later, I later searched it online. I found that I have introduced the MySQL's My.ini file, add a line in [mysqld] in My.ini: default-character-set = GBK, then restart mysql. This method is not tested because it is designed to restart MySQL. I don't know if it is feasible.

But find more default charset properties in SQL creation with EMS MySQL. Default is latin1.

Create Table `TMP_4`

`ID` Tinyint (4) Not null auto_increment,

`a` char (1) Default Null,

Primary key (`ID`),

UNIQUE Key `ID` (` ID`)

ENGINE = Myisam default charset = latin1

So change SQL to Default Charset = GBK and recreate the table. Chinese issues are so solved. However, the only bad thing is that in MySQL is the character such as ???, it cannot be viewed via the console. I haven't found a good way yet, I don't know if I have modified my.ini's way, you can test it.

转载请注明原文地址:https://www.9cbs.com/read-65204.html

New Post(0)