eclipse向MySQL workbench插入中文显示乱码

来源:互联网 发布:dota2公开比赛数据 编辑:程序博客网 时间:2024/05/29 09:29

eclipse向MySQL workbench插入中文显示乱码

问题描述如下:我们在eclipse中向MySQL中插入数据

statement.executeUpdate("INSERT INTO word VALUES'鲜花''2')");

然而我们发现
这里写图片描述
解决方法:我们为mysql数据库的连接字符串设置编码方式
将原先的代码

Connection  c =DriverManager.getConnection("jdbc:mysql://localhost:3306/words","root","");

修改为

Connection c =DriverManager.getConnection("jdbc:mysql://localhost:3306/words?characterEncoding=utf8","root","");
0 0
原创粉丝点击