String handling and encoding between Java and Oracle -


I have some code that does something like this:

  string incoming Content = getContent (); If (incoming content.line ()> 14) {incoming content substrings (0, 14); }  

GetContent () returns a string with the text "Lorem Ipsum § Lorem ipsum"

The returned string is saved in an Oracle database, but Oracle complains that the string is greater than the column size. The column size is defined as VARCHAR2 (14 BYTE) .

Why is there any idea? I suspect that this is the character in the § string but I'm not sure. I know that Oracle database only supports UTF-8, can it be the reason for wrong size / string length?

JAVA says that it is 14 letters, but Oracle thinks it is not like that.

Because the data type in oracle is byte instead of alignment CRAR Alignment You are eating out of 14 of the "slots" available at the end with any multi-byte characters. For example, VARCHAR2 (2 BYTE) will have two 1-byte characters or only one 2-byte character (and not all 3-byte characters in all). In Java, however, substring () will also count 2-byte characters in the form of a single character so that you can send a lot of data for the Oracle column.

You can use VARCAHR2 (14 CR) in Oracle (which will create 14 multi-byte characters) and make your Java programming easy, or you can Can come with an algorithm which calculates the number of bytes, trim according to a string and accordingly (make sure not to cut multi-byte characters in between).


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -