项目场景:
使用工具:IDEA2020版,SequelPro数据库客户端
问题描述:
想要数据库显示中文,没有出现,只出现了?
create table acc(
id int primary key AUTO_INCREMENT,
name varchar(15),
money double(10,2)
);
insert into acc (name,money) values("小王",200);
在使用jdbc连接数据库时,中文显示??
原因是:我们都没有指定字符集!!!
解决方案:
一、建表时:在最后的分号前添加下面的代码就可以了:
ENGINE=InnoDB DEFAULT CHARSET=utf8;
效果如下:
create table acc(
id int primary key AUTO_INCREMENT,
name varchar(15),
money double(10,2)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into acc (name,money) values("小王",200);
二、在配置文件中配置url时多添加该行代码就好了
?characterEncoding=utf-8
效果: