Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Storing Kanji charaters into database

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic