Are escape sequences stored in CLOBs?

We use Java and Oracle for development.

I have a table in an oracle database that has a CLOB column in it. Some XYZ applications download a text file in this column. The text file has several lines.

Is it possible that when reading the same CLOB file through a Java application, escape sequences (new string characters, etc.) may get lost?

The reason I asked this is that we analyze this file line by line, and if the escape sequences are lost, then we will be a problem. I would do this analysis myself, but I'm on vacation, and my team needs urgent help.

It would be very helpful if you could provide any thoughts / materials.

+3
source share
3 answers

You need to make sure that you use the same correct and same character encoding throughout the process. I highly recommend you a pickup UTF-8for this. It covers every human character known in the world. Each step that involves processing character data should be instructed to use the same encoding.

In the context of SQL, verify that the database and table are created using UTF-8charset. In the context of JDBC, verify that the JDBC driver uses UTF-8; this is often configured using the JDBC connection string. In the context of Java code, make sure you use UTF-8when reading / writing character data from / to streams; you can specify it as the 2nd argument of the constructor in InputStreamReaderand OutputStreamWriter.

+2

CLOB . , . XYZ CLOB , , .

" XYZ" \r (Mac), \r\n (DOS/Windows), \n (Unix/Linux), . , BufferedReader.readLine() , .

+1

I am not 100% sure what you mean by sketch sequences in this context. Inside (for example) a literal string, Java "\n"is an escape sequence representing a new string, but as soon as this string is output to something (say, a database), it is no longer an escape sequence, it is the actual newline character.

Anyway, to your direct question, Java through can read text from Oracle CLOB perfectly. New lines are not lost.

0
source

Source: https://habr.com/ru/post/1726930/


All Articles