George H wrote:
Hi I'm a bit new to derby and I got stuck with escaping special
characters like \n and \r.
I'm constructing SQL insert statements in my java program and placing
text inside which contain EOLs. They are not being escaped or
something.
I'm familiar with MySQL in that it converts all \n to \\n, this does
not seem to work with derby, what does?
--
George H
[email protected]
Hi George,

Can you phrase your INSERT in terms of a JDBC '?' parameter? E.g.,

PreparedStatement ps = connection.prepareStatement( "INSERT INTO fooTable( stringColumn ) values ( ? )" )

If so, then you just have to set the ? parameter equal to some Java string. All you need is the String escaping you use in other Java programs:

 ps.setString( 1, "My string which contains\nsome newlines\n" );

Hope this helps,
-Rick

Reply via email to