简体   繁体   中英

Mysql latin characters issue in java

I have a table named 'tasks' with columns taskid, taskname and 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.

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'.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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