File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes CharacterSet in OJDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "CharacterSet in OJDBC" Watch "CharacterSet in OJDBC" New topic

CharacterSet in OJDBC

Karthika Srinivasan

Joined: Nov 13, 2011
Posts: 1

I have a query regarding the Character Set class in ojdbc.jar. I am using ojdbc5.jar. My application uses JAVA and Oracle 10 DB running OC4J.

I have a String(java.lang) which I'm converting it to a oracle sql type 'Char' using the CharacterSet. The value that I use for Character Set is DEFAULT_CHARSET.

CharacterSet charset = CharacterSet.make(CharacterSet.DEFAULT_CHARSET);

if (o instanceof String) {
return new CHAR((String) o, charset);
When I debugged the code, I see the value of charset as 31 which corresponds to ISO_LATIN and 8859P1.
I have Russian Characters in my String because of ISO_LATIN and 8859P1, Russian characters are not recognized and they return Junk values. I wanted DEFAULT_CHARSET to return 871 which corresponds to UTF-8 so that it recognizes Russian characters. I don't want to hard code UTF-8 in the code rather do changes such that default charset points to UTF-8.

How do I do that? Why is DEFAULT_CHARSET returning 31? My DB also has its default charset as UTF-8.

Please help. This is quite urgent to me. Your thoughts are very much appreciated.

Thanks in advance,
Justin Carter

Joined: Jan 13, 2010
Posts: 9
It appears that the DEFAULT_CHARSET represents the database character set, so there is nothing that can be done from a coding perspective that can change this value.
See the notes found here:

I see two possibilities:
(1) Consider a database character set migration.
(2) If you want to solve this from a coding standpoint, but don't want to hard-code a value everywhere you need to reference a charset, you could always create a class that has the charset value as a public static final member. That way, if you ever need to change it, it can be changed in one file/location rather than everywhere in your code.

I agree. Here's the link:
subject: CharacterSet in OJDBC
It's not a secret anymore!