JSP uses UTF-8 link MYSQL database (UTF8) garbled and connection failure problems and more _ MySQL

Source: Internet
Author: User
JSP use UTF-8 link MYSQL database (UTF8) garbled and connection failure issues and change mysql default encoding JSP use UTF-8 link MYSQL database (UTF8) garbled and connection failure issues:

Preface: the databases used by these big companies are not human-friendly... It took me a long time to get it done.

Csdn does not seem to be able to transmit images anymore... I would like to have a few images...

1. in windows mysql database is utf8 encoding, the connection fails (note that mysql is not a UTF-8, but utf8) Status, display? On the web page (UTF-8 encoding set for the web page)User ID number user name user password user address 47g? 1243null48? 1243null49? 1231243null50? 231243null51? 31243 null When the database sets the client language to GBK, it can be displayed. it is assumed that utf8 encoding is used internally. after the setting, it will be converted to GBK encoding:

Mysql> set names gbk
->;
Query OK, 0 rows affected (0.00 sec)

Mysql> select * from user;
+ -------- + ----------- + -------------- + ------------ +
| Userid | username | userpassword | useradress |
+ -------- + ----------- + -------------- + ------------ +
| 1 | me | NULL |
| 2 |? 2 | 1243 | NULL |
| 3 | ?? 37fg459| 1243 | NULL |

Of course, if you use utf8 encoding, it will be garbled. it is assumed that the default windows encoding is GBK, so utf cannot be displayed.

Mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)

Mysql> select * from user;
+ -------- + ----------- + -------------- + ------------ +
| Userid | username | userpassword | useradress |
+ -------- + ----------- + -------------- + ------------ +
| 1 |

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.