2
我正在使用hector在cassandra DB中插入值。我使用Eclipse helios IDE和Cassandra 1.1.2版,並在我的類路徑中導入了以下jar文件。無法在卡桑德拉分貝中使用Hector插入值
- Apache的卡桑德拉-1.1.2.jar
- 威嚇核-0.7.0.29.jar
- libthrift-0.8.0.jar
- SLF4J-API-1.6.6.jar
我不明白這裏有什麼問題,兼容性問題或與代碼混淆的東西。
我試過使用不同版本的罐子,但沒有運氣。 以下是代碼片段。
請幫忙。
int count = 0;
StringSerializer ss = StringSerializer.get();
String cf = "TESTING";
CassandraHostConfigurator conf = new CassandraHostConfigurator("10.100.10.177:8160");
System.out.println("host configured..");
conf.setCassandraThriftSocketTimeout(40000);
conf.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_BLOCK);
conf.setRetryDownedHostsDelayInSeconds(5);
conf.setRetryDownedHostsQueueSize(128);
conf.setRetryDownedHosts(true);
conf.setLoadBalancingPolicy(new LeastActiveBalancingPolicy());
String key = Long.toString(System.currentTimeMillis());
Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", conf);
Keyspace keyspace = HFactory.createKeyspace("Testing", cluster);
Mutator<String> mutator = HFactory.createMutator(keyspace, StringSerializer.get());
while (!"q".equals(new Scanner(System.in).next().toString())) {
try {
mutator.insert(key, cf, HFactory.createColumn("column_" + count, "v_" + count, ss, ss));
mutator.execute();
count++;
} catch (Exception e) {
e.printStackTrace();
}
}
這是當我插入一個沒有循環的值時得到的異常。
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cassandra.thrift.Column.<init>(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;J)V
at me.prettyprint.cassandra.model.HColumnImpl.<init>(HColumnImpl.java:36)
at me.prettyprint.hector.api.factory.HFactory.createColumn(HFactory.java:477)
at me.prettyprint.hector.api.factory.HFactory.createStringColumn(HFactory.java:488)
at ExampleDaoV2.main(ExampleDaoV2.java:66)
嗨, 我還在爲此苦苦掙扎,任何人都可以幫忙。 – Sohan 2012-08-17 13:10:54