[英]com.datastax.driver.core.exceptions.InvalidQueryException using Datastax Java driver
I created my column family like this from the CLI- 我从CLI创建了这样的列系列
create column family profile
with key_validation_class = 'UTF8Type'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and column_metadata = [
{column_name : account, validation_class : 'UTF8Type'}
{column_name : advertising, validation_class : 'UTF8Type'}
{column_name : behavior, validation_class : 'UTF8Type'}
{column_name : info, validation_class : 'UTF8Type'}
];
Now I was trying to insert into this column family using the Datastax Java driver- 现在我尝试使用Datastax Java驱动程序插入此列族 -
public void upsertAttributes(final String userId, final Map<String, String> attributes) {
String batchInsert = "INSERT INTO PROFILE(id, account, advertising, behavior, info) VALUES ( '12345', 'hello11', 'bye2234', 'bye1', 'bye2') ";
CassandraDatastaxConnection.getInstance().getSession().execute(batchInsert);
}
I am always getting this exception- 我总是得到这个例外 -
com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured columnfamily profile com.datastax.driver.core.exceptions.InvalidQueryException:unconfigured columnfamily profile
And by this way, I am trying to create connection/session initialization to Cassandra using Datastax java driver- 通过这种方式,我试图使用Datastax java驱动程序创建连接/会话初始化到Cassandra-
private CassandraDatastaxConnection() {
try{
cluster = Cluster.builder().addContactPoint("localhost").build();
session = cluster.connect("my_keyspace");
} catch (NoHostAvailableException e) {
throw new RuntimeException(e);
}
}
I am running Cassandra 1.2.3. 我正在运行Cassandra 1.2.3。 And I am able to connect to Cassandra using the above code. 我可以使用上面的代码连接到Cassandra。 The only problem I am facing is while inserting. 我面临的唯一问题是插入时。
The thing that I wanted to know is whether I can insert into Column Family (that I have created from CLI mode) using Datastax Java driver or not? 我想知道的是我是否可以使用Datastax Java驱动程序插入Column Family(我是从CLI模式创建的)? As soon as I am trying to insert into Column Family which I have created in CLI mode, I always get the above exception. 一旦我尝试插入我在CLI模式下创建的Column Family,我总是得到上述异常。
But If I try to insert into another table that I have created in CQLsh mode
, I am able to insert into that. 但是,如果我尝试插入我在CQLsh mode
创建的另一个表,我可以插入到该表中。
Any help will be appreciated. 任何帮助将不胜感激。
我的猜测:您的CLI列系列位于不同的键空间中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.