问题描述
我连接到具有NLS_CHARACTERSET(WE8ISO8859P1)的Oracle数据库,据我所知,我不知道不支持存储阿拉伯文本。
I connect to Oracle database which has NLS_CHARACTERSET (WE8ISO8859P1) , which as far as I know cannot support storing Arabic text.
但是Toad for Oracle可以读取阿拉伯语这个数据库:
But Toad for Oracle can read Arabic from this database:
但是,我无法使用java代码
However, I cannot read this using java code.
即使我尝试使用UTL_RAW.CAST_TO_RAW
even I tried to get row of them in bytes using UTL_RAW.CAST_TO_RAW
以字节为单位获取行218,227,237,225,228,199,32,199,225,218,210,237,210,161,225,222,207,32,199,211,202,229,225,223,202,32,32,56,48,37,32,227,228,32,230,205,207,199,202,32,221,225,237,223,211,32,32,32
The result was "218,227,237,225,228,199,32,199,225,218,210,237,210,161,225,222,207,32,199,211,202,229,225,223,202,32,32,56,48,37,32,227,228,32,230,205,207,199,202,32,221,225,237,223,211,32,32,32"
在测试java类中,我尝试使用上述字节创建新的String(新的char [] {}),没有运气显示阿拉伯字符。
In a test java class, I tried to create new String(new char[]{}) using the above mentioned bytes, with no luck to display Arabic characters.
任何帮助?谢谢。
推荐答案
这可能是由于以下几点:
This could be caused by quite a few things:
-
检查数据库中的列类型应为
NVARCHAR
不是VARCHAR
(注意单词开头的N)
Check the column type in database it should be
NVARCHAR
notVARCHAR
(notice the "N" at the beginning of the word)
尝试放入 = utf8
连接字符串
将字节[]
转换为字符串使用这样的UTF-8编码
Convert the byte[]
to string using UTF-8 encoding like this
String arabicText = new String(byteArray, "UTF-8");
这篇关于从使用java的WE8ISO8859P1编码的Oracle数据库中读取阿拉伯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!