I have an application that uses PreparedStatements, which 99% of the time
works great with embedded quote (") and single-quote (') characters without
doing any explicit escape sequences.
The 1% is where I have a problem. If the setString() call on my prepared
statement starts with a quote (") or single-quote (') character, InstantDB
skips it and goes to the next character. Obviously, this starting quote
character is very important to my application. I have tried prepending a
slash to the string, but InstantDB then complains with:
Unknown escape character: \
My code (snippet of):
PreparedStatement stmt = conn.prepareStatement(
"INSERT INTO MY_TABLE (aString) VALUES (?)");
s = //someString;
// if it starts with a quote or single-quote, prepend the slash
c = s.charAt(0);
if (c == '"')
{
s = "\\" + s;
// I even tried
// s = "\\\"" + s.substring(1);
}
else if (c == '\'')
{
s = "\\" + s;
}
stmt.setString(1, s);
Any help or suggestions?
Thanks.
Gary Myers
-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.
|