Chinese garbled characters are displayed when a jsp is inserted into the mysql database.

Source: Internet
Author: User
When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows: When jsp inserts data into mysql, the unified encoding is set on the jsp page first: request. setCharacterEncoding (UTF-8); then, when creating a database and a table, specify the unified encoding utf8, as follows: 1. When creating a database: CREATEDATABAS

When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows: When jsp inserts data into mysql, the unified encoding is set on the jsp page first: request. setCharacterEncoding (UTF-8); then, when creating a database and a table, specify the unified encoding utf8, as follows: 1. When creating a database: CREATE DATABAS

When jsp inserts mysql, the Chinese characters are garbled and the information for one morning is searched. The solution is recorded as follows:

When jsp inserts data into mysql, it first sets the unified encoding on the jsp page: request. setCharacterEncoding ("UTF-8 ");

Then, specify the unified encoding format utf8 during database creation and table creation. The format is as follows:

1. When creating a DATABASE: create database 'test'
Character set 'utf8'
COLLATE 'utf8 _ general_ci ';
2. create table 'database _ user '(
'Id' varchar (40) not null default '',
'Userid' varchar (40) not null default '',
) ENGINE = InnoDB default charset = utf8;

Modify the my. ini file in the default installation directory of mysql and change the default latain1 encoding format to UTF8.

When establishing a connection with mysql, change the url to the following format:

Url = jdbc: mysql: // localhost: 3306/database? UseUnicode = true & characterEncoding = UTF8

In this way, the connection method will be changed to the UTF8 format during connection.


In the command console, use show variables like 'Char % 'to view the current default connection mode.

Set character_set_server = 'utf8'; to modify the default connection mode.




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.