我已经编写了用于从 cassandra 读取记录的 java 代码。但它给出了运行时错误..这是java代码: -
import javax.naming.spi.DirStateFactory.Result;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.*;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.beans.HColumn;
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.mutation.Mutator;
import me.prettyprint.hector.api.query.ColumnQuery;
import me.prettyprint.hector.api.query.QueryResult;
public class HectorConnect {
public static void main(String args[]){
try{
Cluster c = HFactory.getOrCreateCluster("Test", "localhost:9160");
Keyspace ko = HFactory.createKeyspace("myspace", c);
StringSerializer se = StringSerializer.get();
ColumnQuery<String, String> q = HFactory.createColumnQuery(ko, se, se);
QueryResult<HColumn<String, String>> r = q.setKey("cara").
setName("customername").
setColumnFamily("customer").
execute();
}
catch(Exception e){
e.printStackTrace();
}
}
}
它抛出的错误如下: -
log4j:WARN 找不到记录器的附加程序(me.prettyprint.cassandra.service.CassandraClientPoolFactory)。log4j:WARN 请正确初始化 log4j 系统。线程“主”java.lang.NoSuchMethodError 中的异常:org.apache.cassandra.thrift.Cassandra$Client.describe_keyspaces()Ljava/util/Set; 在 me.prettyprint.cassandra.service.CassandraClientImpl.getKeyspaces(CassandraClientImpl.java:141) 在 me.prettyprint.cassandra.service.CassandraClientImpl.getKeyspace(CassandraClientImpl.java:114) 在 me.prettyprint.cassandra.service.CassandraClientImpl.getKeyspace (CassandraClientImpl.java:104) 在 me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:57) 在 me.prettyprint.cassandra.model.thrift.ThriftColumnQuery.execute(ThriftColumnQuery.java:34) 在 HectorConnect。主要(HectorConnect.java:
有谁知道解决这个问题??