aspose file tools*
The moose likes JDBC and the fly likes CharacterSet in OJDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "CharacterSet in OJDBC" Watch "CharacterSet in OJDBC" New topic
Author

CharacterSet in OJDBC

Karthika Srinivasan
Greenhorn

Joined: Nov 13, 2011
Posts: 1
Hi,

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,
Karthika
Justin Carter
Greenhorn

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:
http://docs.oracle.com/cd/B14117_01/java.101/b10979/oraint.htm#i1064650

I see two possibilities:
(1) Consider a database character set migration.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch11charsetmig.htm
(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.

 
 
subject: CharacterSet in OJDBC