The Chinese content defined in the MySQL query statement is displayed as a question mark in the Java Web

Source: Internet
Author: User
Tags mysql query java web

Java Web Query, gender word Gencun is the number, 1 for male, 2 for female, take the data when the gender into Chinese characters displayed on the page, the SQL statement as follows, the result has been a problem

Select A.emp_id,a.emp_name, case when a.emp_gendar=1 then ' Male ' when a.emp_gendar=2 then ' female ' end as Emp_gendar, B.post_name
From T_employee_info A, T_position_info b
where a.post_id = b.post_id; Gender in the page does not appear, the display is a question mark, is expected to show male or female, online search data found is due to the improper setting of MySQL character encoding, mysql default character encoding is latin1, does not support Chinese, you must set the database encoding to support the Chinese encoding, in order to display correctly. Enter the database, enter: Show variables like ' character_set_% '; Discover Character_set_serverUTF8The value for Latin1 is found in the MySQL installation directory, locate the My.ini file, locate the [client] and [mysqld] fields in the My.ini file, add Default-character-set=utf8 below, save and close, Restart the MySQL service. Open and re-enter: Show variables like ' character_set_% '; Get the following results

You can then run the Web program, and the gender is shown as male and female as expected.

The Chinese content defined in the MySQL query statement is displayed as a question mark in the Java Web

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.