开发者

oracle + java encoding problem while insert

开发者 https://www.devze.com 2023-02-01 08:27 出处:网络
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 oracl

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 fea开发者_开发百科sible 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.


Make the characterset to UTF8.


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

0

精彩评论

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

关注公众号