我的代码:
public class InsertSuperColumn {
private static StringSerializer stringSerializer = StringSerializer.get();
public static void main(String[] args) throws Exception {
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");
Keyspace keyspaceOperator = HFactory.createKeyspace("Keyspace1", cluster);
try {
Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer);
mutator.insert("billing", "Super1", HFactory.createSuperColumn("jsmith",
Arrays.asList(HFactory.createStringColumn("first", "John")),
stringSerializer, stringSerializer, stringSerializer));
SuperColumnQuery<String, String, String, String> superColumnQuery =
HFactory.createSuperColumnQuery(keyspaceOperator, stringSerializer, stringSerializer,
stringSerializer, stringSerializer);
superColumnQuery.setColumnFamily("Super1").setKey("billing").setSuperName("jsmith");
QueryResult<HSuperColumn<String, String, String>> result = superColumnQuery.execute();
System.out.println("Read HSuperColumn from cassandra: " + result.get());
System.out.println("Verify on CLI with: get Keyspace1.Super1['billing']['jsmith'] ");
} catch (HectorException e) {
e.printStackTrace();
}
cluster.getConnectionManager().shutdown();
}
}
我收到此错误:
Exception in thread "main" me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Keyspace names must be case-insensitively unique ("new2" conflicts with "new2"))