java mysql insert database Chinese change question mark solution

1. my.ini settings: utf-8

 

2、create database wood default character set utf8 collate utf8_general_ci;

CREATE TABLE `tbl_privs_role` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `role_number` varchar(255) DEFAULT NULL,

  `role_name` varchar(255) DEFAULT NULL,

  `role_state` int(3) DEFAULT NULL COMMENT '0: add 1: in use 2: void 3: delete',

  `insertDate` date DEFAULT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

 

3. All the settings are still saved to the mysql database, the Chinese becomes a question mark,

 

jdbc:mysql://localhost:3306/bb?useUnicode=true&characterEncoding=utf-8

 

Problem completely solved! If your connection string is in the xml file, please change & to & when the client connects, the default seems to be GBK, so specify utf8

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326206546&siteId=291194637