The role of useunicode=true&characterencoding=utf-8 in MySQL connection URL

Source: Internet
Author: User

When we connect MySQL database, we usually add useunicode=true&characterencoding=utf-8 after the URL, but ask what to add?

The purpose of the addition is to specify the encoding and decoding format of the characters.

For example: the MySQL database uses GBK encoding, and the project database uses UTF-8 encoding. If Useunicode=true&characterencoding=utf-8 is added at this time, then there are two aspects of the function:

1. When data is stored:

when storing the project data, the database decodes the data into bytecode using the UTF-8 format, and then the decoded bytecode is reused in the database using the GBK encoding.

2. When data is taken:

when fetching data from the database, the database will first decode the data in the database into bytecode in GBK format, then encode the decoded bytecode again in UTF-8 format, and then return the data to the client.

Note: When you configure Database utl in an XML configuration file, you use the & escape character, which is &

Example: <property name= "url" value= "jdbc:mysql://localhost:3306/email?useunicode=true&amp;characterencoding= UTF-8 "/>

Special characters commonly used in HTML:

Most commonly used character entities (Character entities) Number
Show Results Description Entity Name Entity
Show a space &nbsp; & #160;
< Less than &lt; & #60;
> Greater than &gt; & #62;
& & Symbols &amp; & #38;
" Double quotes &quot; & #34;
Other commonly used character entities (Character entities) Number
Show Results Description Entity Name Entity
© Copyright &copy; & #169;
® Registered trademarks &reg; & #174;
X Multiplication sign &times; & #215;
÷ Division Sign &divide; & #247;

Transfer from http://www.cnblogs.com/xuefuwu/archive/2012/05/06/2486577.html

The role of useunicode=true&characterencoding=utf-8 in MySQL connection URL

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.