Java Web Background Insert Database Chinese garbled problem solving

Source: Internet
Author: User
Tags java web mysql command line

Objective: To avoid garbled occurrences, keep the server, database, project, and front-end code consistent.
First, the project and the front-end code, set.

MyEclipse---> Right-click Project--->properties--->resource--->text file encoding-----> select UTF-8---->apply--- >ok

Second, tomcat6.x server encoding settings

D:\apache-tomcat-6.0.37\conf\server.xml,

[HTML]View plain copy
    1. <Connector port="8080" protocol="http/1.1 "
    2. connectiontimeout="20000"
    3. redirectport= "8443" uriencoding="UTF-8"/>
[HTML]View plain copy
    1. <Connector port="8009" protocol="ajp/1.3" redirectport="8443" uriencoding= "UTF-8"/>


The uriencoding= "UTF-8" in the back is what is added.

Third, the database MySQL5.5 settings;

① first open the service running--->cmd--->net stop mysql off MySQL

②c:\program Files (x86) \mysql\mysql Server 5.5\my.ini

Modify the following four fields

[HTML]View plain copy
    1. [Client]
    2. Port = 3306
    3. default-character-set=UTF8
[HTML]View plain copy
    1. [MySQL]
    2. default-character-set=UTF8
[HTML]View plain copy
    1. [Mysqld]
    2. character-set-server=UTF8
    3. Port = 3306
[HTML]View plain copy
    1. character-set-server=UTF8

Save.

③ Open Run--->cmd--->net start mysql on MySQL service
④ open MySQL command line interface, enter the password after entering

Execute show variables like ' character% '; the statement, which appears as follows, indicates that the setting was successful


Java Web Background Insert Database Chinese garbled problem solving

Related Article

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.