문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top