gpt4 book ai didi

mysql - MySQL 和 jdbc 中的类似运算符和西里尔字母

转载 作者:行者123 更新时间:2023-11-29 12:19:02 26 4
gpt4 key购买 nike

为什么一切会变成这样? http://cs621724.vk.me/v621724427/19ade/rqgKgpzZPbU.jpg

create table b(tt varchar(2));
insert into b select 'ы ';
SELECT * FROM allservices.b;

工作台的结果是 # TT 'ы'但是使用 jdbc...

        connection = initConnection();
statement = connection.prepareCall("select tt from b where tt like '%ы%'");
resultSet = statement.executeQuery();
System.out.println("----------");
while (resultSet.next()) {
System.out.println(resultSet.getString("tt"));
}
System.out.println("==========");
statement = connection.prepareCall("select tt from b where tt like '%'");
resultSet = statement.executeQuery();
System.out.println("----------");
while (resultSet.next()) {
System.out.println(resultSet.getString("tt"));
}
System.out.println("==========");

结果是: ---------- ========= ---------- û =========

最佳答案

set names utf8;  -- To say your client is using utf8 encoding
create table b(tt varchar(2) CHARACTER SET utf8); -- to say the column is utf8

插入后,执行以下操作:

mysql> select hex(tt) from b;
+---------+
| hex(tt) |
+---------+
| D18B20 | -- You should see this. D18B is the yery ('ы') character; 20 is space.
+---------+

关于mysql - MySQL 和 jdbc 中的类似运算符和西里尔字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29322739/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com