开发者

Problem reading special characters from teradata - JDBC

I use teradata and the below query outputs "Altlüd" when run using a teradata client.

select name as name  from MYTABLE where selector=?

Whereas, I get "Altl?d" as the output when I try to execute the query using a java client(jdbc with teradata drivers). I am using "UTF-8" charset and I have also tried Latin charset with no luck.

I have also tried this to troubleshoot.

while (rs.next()) 开发者_运维百科{
 System.out.println(rs.getString(1));
 Reader rd = rs.getCharacterStream(1);
 int charr = rd.read();
 while (charr >= 0) {
    System.out.println(charr + " = " + ((char) charr));
    charr = rd.read();
 }
}

And the output is

Altl?dersdorf 65 = A 108 = l 116 = t 108 = l 65533 = ? 100 = d

If you look at the output produced, the int value for the spl character is 65533 which shouldn't be the case.

Infact it returns 65533 for all the special characters.

Any clues/pointers will be appreciated. Thanks!!!


Seems to be the Unicode Replacement character U+FFFD. JDBC client and server do not use the same encoding for characters. The client seems to try UTF-8, but the server does offer any non UTF format.

I do not know teradata, but you should look for any database and or server settings for the encoding and/or locale.


Try to use CHARSET=UTF-16 as client side parameter.

One easy way is to set LC_ALL = LANG = en_US.UTF-16 and then run your Java program.


Use CHARSET=UTF16 instead of CHARSET=UTF-16, more information can be found https://docs.teradata.com/reader/pk_W2JQRhJlg28QI7p0n8Q/tE40Yeyi9_0_~khKoRUbFA

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜