开发者

Cassandra CQL unable to insert (no viable alternative at input)

After setup cassandra (0.8.4) and tested with insert and select via CLI, i move on to JDBC (1.0.3) with CQL.

This is where, i encounter SQLException on following code, any idea?

Connection conn =  DriverManager.getConnection(url);             

String sql = "INSERT INTO row (KEY, first, last, age) VALUES ( 'Jones', 'Jones', 'Lang', '32');"; // interna开发者_Python百科l error
Statement stmt = conn.createStatement();
stmt.execute(sql);

The exception:

java.sql.SQLException: line 1:22 no viable alternative at input 'first'
at org.apache.cassandra.cql.jdbc.CassandraStatement.execute(CassandraStatement.java:160)
at Cassandra.Insert.main(Insert.java:22)


first is a CQL keyword, you need to put it in quotes. Try:

String sql = "INSERT INTO row ('KEY', 'first', 'last', 'age') VALUES ( 'Jones', 'Jones', 'Lang', '32');";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜