Hi all,
first, i'm new to Cassandra. I'm use Cassandra 0.8.2 with CQL JDBC Driver
Version 1.0.3.
My problem is, that I have to insert a large amount of weather data to
Cassandra via JAVA. Some of the weather station have single quotes in their
name.
When I insert them directly via a Statement, i got a SQLException: mismatched
character '<EOF>' expecting '''.
Code is something like this:
Statement stmt = connection.createStatement();
stmt.execute("INSERT INTO station (KEY, name, ...) VALUES ('" + key + "', '" +
name "', ... + ");");
Therefore I tried to escape the single quotes via following method:
public String escapeString(String string) {
StringBuilder result = new StringBuilder();
StringCharacterIterator it = new StringCharacterIterator(string);
char c = it.current();
while (c != CharacterIterator.DONE) {
if (c == '\'') {
result.append('\\');
result.append('\'');
} else {
result.append(c);
}
c = it.next();
}
return result.toString();
}
But this also doesn't work.
Is there a way, to insert Strings with single quotes to Cassandra via CQL?
Thanks,
Jens
--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone