我使用cql 3(使用Cassandra 1.1.12)
创建了一个如下表Create table User (
... userid varchar,
... password varchar,
... email varchar,
... gender varchar,
... fullName varchar,
... dateOfBirth varchar,
... bloodGroup varchar,
... ethnicity varchar,
... PRIMARY KEY (userid)
... );
但是使用hector api,我无法在列族中插入数据。
Mutator<String> mutator = HFactory.createMutator(emr, ss);
System.out.println("Inserting");
mutator.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(FULL_NAME, user.getFullName()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(EMAIL, user.getEmail()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(DOB, user.getDateOfBirth()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(BLOOD_GROUP, user.getBloodGroup()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(PASSWORD, user.getPassword()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(ETHNICITY, user.getEthnicity()))
.addInsertion(user.getUserID(), USER, HFactory.createStringColumn(GENDER, user.getGender()));
mutator.execute();
提供以下错误
线程“main”中的异常me.prettyprint.hector.api.exceptions.HInvalidRequestException:InvalidRequestException(why:unconfigured columnfamily User)
有人可以帮忙吗?
答案 0 :(得分:0)
原因:未配置的columnfamily用户
此异常表示您尝试插入尚未创建的CF.创建列族user
,然后上面应该可以工作。