Mysql4.1 character set explanation (turn to hibernate 中文 网)

xiaoxiao2021-03-06  19

The mysql database 4.1 is a watershed, 4.1 directly supports Unicode, the following version is not good; Mysql JDBC Driver's 3.0.16 is also a watershed, 3.0.16 will take the database itself encoded, then follow the encoding conversion, this The way and Oracle's JDBC Driver is the same. For example, your database is GBK encoding, JDBC Driver will convert the outgoing strings in the database to Unicode, to the JVM. Therefore, the correct setting of the database itself is particularly important. The version of MySQL JDBC Driver 3.0.16 does not, it will not be so intelligent to determine how to convert according to database encoding, it always uses ISO8859-1 by default, so you have to use characterEnderEnderEnderEnderEnderEnderEnderEnderEnding = GBK to force him to take it out of the database. The string is converted to Unicode in GBK. Therefore, what database version is used, whether it is 3.x, or 4.0.x or 4.1.x, in fact, it is not important to us, and important two: 1) correct setting database encoding, MySQL4.0 below The character set is always the default ISO8859-1, MySQL4.1 will make you choose when installing. If you are ready to use UTF-8, you will specify UTF-8 when you create a database (you can change it later, 4.1 or above can also specify the character set of the table separately) 2) Use 3.0.16 or more JDBC Driver, then you don't need to write anything again. CHARACTERENCODING = UTF-8

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

New Post(0)