• 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

rs.getBytes() rarity

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a RDB database with one column in utf-8 encoding for Chinese text. Now I want to know how many bytes the text takes. Well, we know how much it takes, but we want to see it in software.

So, I use the getBytes()-method of the ResultSet. For all Chinese characters it returns 2, but I doubt this is correct because when I use the getString().getBytes() of the ResultSet it returns 3 and with the SQL function LENGTHB() the result is also 3.

Finally, I try to make a String from the bytearray that is returned by the getBytes()-method of the ResultSet and compared it with the one that is returned by the getString() from the ResultSet.
If the text isn't Chinese, the 2 Strings are equals. But otherwise they aren't.


Is it possible that the getBytes() method of the ResultSet isn't correct? (Driver is a JDBC-RDB driver)

Hope you can understand what i'm trying to say.


output

 
reply
    Bookmark Topic Watch Topic
  • New Topic