This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes Chinese characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Chinese characters" Watch "Chinese characters" New topic
Author

Chinese characters

visu Nekk
Ranch Hand

Joined: Sep 06, 2005
Posts: 122
Hi,

When I query a web service, I get values which are sometimes in clear text and sometimes text+chinese characters. I assign the value to a String and when I try to insert it into Oracle database with classes12.jar, I get an "Invalid Character" exception. What could be the problem?

Thanks,
Visu
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What character set is your Oracle database configure to use? If you want to store Chinese characters you will need to use a suitable encoding (Unicode would be easiest).

That aside, if you are actially seeing a error performing the insert my guess is you are not using PreparedStatament? You could try using one instead, see if the error goes away.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
visu Nekk
Ranch Hand

Joined: Sep 06, 2005
Posts: 122
Thanks Paul,

The database encoding is utf8. Do we need to add set the encoding in the code also? Is PreparedStatement an option to handle this kind of stuff or is it mandatory?

Visu
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No you don't. In Java, all strings are Unicode.

PreparedStatement's avoid any character escaping issues.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chinese characters