InstantDB Project
About InstantDB
Project Mail Lists
Short History
Reporting Bugs
Screen Shots
3rd Party Examples
FAQs

Software
Downloads
Documentation
CVS Repositories
Roadmap
License

About Enhydra.org
Who We Are
News, Articles & Events
Getting Involved
Contact Us

Community
Demos
Contributions
Resources
Case Studies
On The Edge! -NEW-
Commercial Vendors


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: InstantDB: Embedded Quotes


Gary

For reasons that even I can't figure out, InstantDB always assumes that you
don't want the external quotes or double quotes on a string literal. But as
you've discovered, it doesn't understand the escape sequence \" unless it's
actually inside a literal. The result of this is that InstantDB has to get a
quoted string with quotes inside of it. Which translates to the following
(pretty horrible) sequence:

p.setString (1,"\"\\\"name2\\\"\"");

What does all that mean? The outer quotes and triple \ are for the Java
compiler's benefit. So what InstantDB sees is:

"\"name2\""

InstantDB assumes you don't want the outer quotes so it parses this as the
string literal:

\"name2\"

As it's now inside of a string literal, it will accept the \" escape
sequence and you finally end up with what you wanted, i.e.:

"name2"

I think the best long term solution here would be for InstantDB to recognise
the \" sequence outside of string literals. In which case you would only
have to provide the slightly less awkward:

p.setString (1,"\\\"name2\\\"");

For the moment though, I'm afraid you're stuck with the above solution.

Regards

Peter Hearty
Lutris Technologies (UK)
----- Original Message -----
From: "Gary Myers" <gary.myers@us.ubizen.com>
To: <instantdb@enhydra.org>
Sent: Wednesday, August 30, 2000 10:32 PM
Subject: InstantDB: Embedded Quotes


> 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 = file://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.
>

-----------------------------------------------------------------------------
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.