Sql query cannot handle special character like ½

classic Classic list List threaded Threaded
4 messages Options
wengyao04 wengyao04
Reply | Threaded
Open this post in threaded view
|

Sql query cannot handle special character like ½

Some of our string fields contain special characters like  ½. When we use get
API to retrieve the object from the cache by key, and print out the field
having special characters,  the special characters are displayed correctly.

However, when we use SqlFieldsQuery to select the field like the following

 String sql = "SELECT id, shortName from Warrant where id = ?";
 QueryCursor<List&lt;?>> cursor = mycache.query(new
SqlFieldsQuery(sql).setArgs("id1235"));
List<List&lt;?>> rows = cursor.getAll();
for (List<?> row : rows) {
    System.out.println(row.get(0) + " " + row.get(1));
}

The special character does not decode correctly, it shows "?" instead of "½"

How could we fix this problem when using SqlFieldsQuery  to query string
field containing special character ?

Thanks



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
akurbanov akurbanov
Reply | Threaded
Open this post in threaded view
|

Re: Sql query cannot handle special character like ½

Could you please try starting your java applications with
-Dfile.encoding=UTF-8 and check if it works?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
wengyao04 wengyao04
Reply | Threaded
Open this post in threaded view
|

Re: Sql query cannot handle special character like ½

Hi I try it, but it does not work



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Sql query cannot handle special character like ½

Hello!

I expect that your System.out is not unicode. Can you try writing to file, sending this file over? Can you do System.out.println(column.charAt(pos))?

Regards,
--
Ilya Kasnacheev


чт, 13 июн. 2019 г. в 22:01, wengyao04 <[hidden email]>:
Hi I try it, but it does not work



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/