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 |