• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CharacterSet in OJDBC

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
BWA HA HA HA HA HA HA! Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic