MySQL character encoding

Source: Internet
Author: User

MySQL database 4.1 is a watershed, and 4.1 directly supports Unicode, which is not supported in the following versions;

MySQL JDBC driver 3.0.16 is also a watershed. Version 3.0.16 will take the database encoding and convert it according to the encoding. This method is the same as that of oracle JDBC driver. For example, if your database is GBK encoded, The JDBC driver will convert the strings in the database to Unicode according to GBK and send them to JVM. Therefore, it is particularly important to correctly set the database encoding.

MySQL JDBC driver3.0.16 or lower version is not, it is not so intelligent according to the database encoding to determine how to convert, it is always the default use of ISO8859-1, therefore, you must use characterencoding = GBK to force it to convert the string obtained from the database to Unicode Based on GBK.

Therefore, what database version is used, whether it is 3.x, 4.0.x or 4.1.x, is not important to us. There are two important aspects:

1) set the correct database encoding, MySQL and earlier versions of the character set is always the default ISO8859-1, mysql4.1 will let you choose when installing. If you are going to use a UTF-8, You need to specify the UTF-8 when creating the database (you can also change it after the creation, 4.1 or a later version can also separately specify the character set of the table)

2) use JDBC driver 3.0.16 or later versions, then you do not need to write what characterencoding = UTF-8

This article from javaeye.com's Robbin in the Forum: http://forum.javaeye.com/viewtopic.php? T = 10317 & START = 45

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.