简体   繁体   English

java中的Mysql拉丁字符问题

[英]Mysql latin characters issue in java

I have a table named 'tasks' with columns taskid, taskname and description.我有一个名为“tasks”的表,其中包含 taskid、taskname 和 description 列。

Description column has values with latin characters like 'ô' .描述列的值带有拉丁字符,如 'ô' 。

SELECT    cast(`taskname` as binary)
FROM  `tasks` TC_1
WHERE  (cast(`description` as binary)  IN ( 'Impôrtant'  ))

When I run a query like this in MySQL, I'm getting the result but when I run the same query using java executequery method, the resultset is empty.当我在 MySQL 中运行这样的查询时,我得到了结果,但是当我使用 java executequery方法运行相同的查询时,结果集为空。

I have tried the below query too:我也尝试过以下查询:

SELECT    cast(`taskname` as binary)
FROM  `tasks` TC_1
WHERE  (cast(`description` as binary)  IN (cast( 'Impôrtant' as binary )))

but facing the same issue.但面临同样的问题。

I think the issue is related to character set.我认为这个问题与字符集有关。

My database character set is 'latin1'.我的数据库字符集是“latin1”。

Note: ignore syntax errors注意:忽略语法错误

I'd suggest using the escape sequence for the character, for the character you gave it'll be \ô.我建议对字符使用转义序列,对于您提供的字符,它将是 \ô。 If you want to find escape codes for other characters you can use https://www.rapidtables.com/code/text/unicode-characters.html .如果要查找其他字符的转义码,可以使用https://www.rapidtables.com/code/text/unicode-characters.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM