wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
 
 
subject: Chinese characters
 
Similar Threads
Parsing Chinese Characters by using Xerces
Byte vs Character streams
Special Characters
Encoding type in J2ME
HELP! displaying chinese characters