Java read and write data garbled problem from MySQL

Source: Internet
Author: User

MySQL uses Latin (iso-8859-1) by default, while Java uses Unicode encoding by default. Therefore, when inserting data into the MySQL database in Java, or when reading data, it is necessary to first convert the encoding method.

1, first view the database encoding method:

Show variables like ' char% '

Make sure that the encoding used by the database is UTF8

2. View the encoding of the Java file:

3, if all is UTF8, the database of Chinese is normal, but read the content is garbled, want to completely solve this problem instead of each restart service to set the encoding method, it is recommended to reinstall MySQL database.

4, when the installation must be in this step

Select the third option and the guarantee is UTF8.

Java read and write data garbled problem from MySQL

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.