• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Storing Kanji charaters into database

Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to store a String into database that contains some special japanese charaters.
The field on the database side is VARCHAR2(4000)

So, from the java code if String has more than 4000 cahracters am taking first 4000 characters only.

if(str.length() > 4000){
// Take first 4000 chars only

This logic did not satisfy the field restrictions on database side if the String contains some special Kanji cahracters. Its giving Exception as the data is too long to fit in.

After that I made the code change as follows as Oracle consider underlying bytes not chars

if(str.getBytes() > 4000){
//Consider characters (from the beginning of String) which
//accounts to less than or equal to 4000 chars

It did not work though. The getBytes() and length() is returning the same value.

Any ideas to sahre?
    Bookmark Topic Watch Topic
  • New Topic