Astyanax 是否支持使用 CQL3 通过准备好的语句“插入”? 我使用最新的 Astyanax 库 1.56.24 和 Cassandra 1.2.1。当我尝试使用 CQL3 执行准备好的语句时:
keyspace.prepareQuery(conn.CF_CONTACTS)
.withCql("INSERT INTO contacts (a, b) VALUES (?, ?);")
.asPreparedStatement()
.withStringValue("123")
.withStringValue("456")
.execute();;
我得到以下异常:
Caused by: InvalidRequestException(why:Cannot execute/prepare CQL2 statement since the CQL has been set to CQL3(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+).)
at org.apache.cassandra.thrift.Cassandra$prepare_cql_query_result.read(Cassandra.java:38738)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
at org.apache.cassandra.thrift.Cassandra$Client.recv_prepare_cql_query(Cassandra.java:1598)
at org.apache.cassandra.thrift.Cassandra$Client.prepare_cql_query(Cassandra.java:1584)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$3$1.internalExecute(ThriftColumnFamilyQueryImpl.java:747)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$3$1.internalExecute(ThriftColumnFamilyQueryImpl.java:742)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:56)
最佳答案
我使用 Astyanax 1.56.31
让这个工作正常。您需要在 AstyanaxConfigurationImpl
实例中设置以下内容:
.setTargetCassandraVersion("1.2")
.setCqlVersion("3.0.0")
关于java - Astyanax 中的 Cassandra CQL3 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14579731/