【Java】Mysql插入中文变为全问号???的问题 解决方法

@Mysql插入中文变为全问号???的问题 解决方法

遇到的问题

https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2246684787...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
https://xueqiu.com/2119138999...
我在使用idea连接数据库时,使用insert语句插入记录时,

`// An highlighted block

String sql2="insert into emp values(12,'赵云',12000,1) ";

int result=st.executeUpdate(sql2);

System.out.println(result);`

* 1

* 2

* 3

* 4

,虽然插入到数据库了,但是出现了中文乱码,像这样
【Java】Mysql插入中文变为全问号???的问题 解决方法

解决办法

1.如果是Java程序,则在url连接的地方加上?useUnicode=true&characterEncoding=utf-8,像这样
【Java】Mysql插入中文变为全问号???的问题 解决方法
我完美解决了这个问题

反思

我觉得乱码问题是数据库和idea的编码方式不一样造成的

以上是 【Java】Mysql插入中文变为全问号???的问题 解决方法 的全部内容, 来源链接: utcz.com/a/96280.html

回到顶部