Still, with PreparedStatement, the content of str1 is literaly put into the column. If you bind a variable, the content is put into the column without any interpretation. No matter how many quotes, ampersands, @ts and pipes are involved.
Joined: Apr 10, 2009
I wasn't arguing with you, it appears we were both typing at the same moment. Thanks for your better answer.
Joined: Sep 22, 2008
Thanks Jan & Alan for this assistance.
Alan! as suggested by you I had reformatted str1 and inserted it into DB through PreparedStatement but I got same outcome.
I believe Jan is right and that we have proved through your suggestion.
If you are using binds (which is good), simply put the CR/LF characters directly into your String, eg.Bind variables send the text into the database as it is, without any parsing or interpreting. Binds will make your life immensely easier.
(Of course, this technique works only when using binds. It would not work with simple Statement, don't even try it.)
Edit: messed up the String constant. Java String literal corresponding to CHR(13)||CHR(10) is "\r\n", not "\n\r" I had there previously. Sorry.
Your file probably contains the characters \n\n. Remember that \n is only a way how to encode the new line character in Java (and several other languages). The compiler replaces these characters with newline. When you read your file, it is (of course) not interpreted by the compiler and therefore the \n characters are left intact in it.
Edit your input file, delete the characters and just press Enter twice where you want the linebreak to be. That should do it.
subject: PreparedStatement is not renderting char(13)/char(10)