甲骨文+插入时java编码问题
我有点被这个问题困住了。我不是java或oracle专家,所以请给出详细的答案:)
我有一个网络服务,可以将一些东西插入数据库。 Web 服务托管在 axis 上。数据库是oracle,具有以下属性:
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CHARACTERSET ZHS16GBK
网络服务托管在Windows Server 2008,英文版上,但我已将系统的区域设置更改为中文,
现在插入后的数据存在编码问题并显示奇怪的字符,例如????,埃克斯克??
jws文件采用GBK编码。并且插入数据库的数据被硬编码在文件中[我们不是从请求中读取它]
[编辑] 只是一件事,将整个数据库更改为 utf-8 是不可行的,因为它有大量的表和数据
[进一步编辑]以使事情更清楚,
机器接受来自两个源的数据。基本上它被用来向我们的订阅用户发送和接收短信/彩信。主要是与 GSM 运营商控制中心一起运行,所有编码均以 GBK 进行处理。另一方面,该机器还接受网站的请求,向用户发送短信/彩信。这里的编码是用UTF-8处理的。如果网站想要向用户发送短信,它将调用本机上的 Web 服务,该服务会将数据插入数据库[我们的问题就在这里]。然后Windows服务不断检查数据库,如果发现任何新的发送短信/彩信的请求,它将发送短信/彩信并删除记录。
旧机器上一切正常,因为它有中文版的 Windows 2003。我们升级到新服务器并在其上安装了 Windows 2008 服务器英文版。现在,Web 服务插入数据库后数据会失真。
I am kind of stuck on this one. im not a java or oracle guru, so please give detailed answers :)
i've a web-service that inserts something into DB. the web-service is hosted on axis. the db is oracle with following properties:
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CHARACTERSET ZHS16GBK
the web-service is hosted on windows server 2008, english version but i have changed the locale of the system to chinese
now the data after insert has encoding problem and shows strange characters like ????,exxk??
the jws file has GBK encoding. and the data that is inserted into the DB is hard-coded in the file [we are not reading it from REQUEST]
[edit]
just one thing, its not feasible to change the whole DB to utf-8 as it has lots of table and data
[further edit] to make things more clear
the machine accepts data from two source. basically it is being used to send and receive sms/mms to our subscribed users. primarily, it operates with the GSM operator control center where all encodings are handled in GBK. On the other hand, the machine also accepts requests from the website to send sms/mms to the users. Here the encoding are handled in UTF-8. If the website wants to send a sms to the user, it will invoke a web-service on this machine which will insert data into db[our problem is here]. then a windows service continously checks the DB and if it finds any new request to send sms/mms, it will send the sms/mms and delete the record.
everything was working fine on the old machine as it had chinese version of windows 2003. we upgraded to a new server and installed windows 2008 server english version on it. and now the data is distorted after the web-service inserts into DB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将字符集设置为UTF8。
Make the characterset to UTF8.
我还建议选择 UTF8 作为数据库字符集。
但要注意,因为默认情况下 java 使用 UTF16 编码。
要设置 java 使用的默认编码,请使用“file.encoding”标志:
java -Dfile.encoding=UTF8 ...
我从未听说过 ZHS16GBK 字符集,但 java 似乎不支持它:
http://download.oracle.com/javase/1.4。 2/docs/guide/intl/encoding.doc.html
I also recommend choosing UTF8 as the database charset.
Beware though, since by default java uses UTF16 encoding.
To set the default encoding used by java, use the 'file.encoding' flag:
java -Dfile.encoding=UTF8 ...
I never heard about the ZHS16GBK charset but it doesn't seem to be supported by java:
http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html