使用Datastax Java驱动程序com.datastax.driver.core.exceptions.InvalidQueryException [英] com.datastax.driver.core.exceptions.InvalidQueryException using Datastax Java driver

查看:527
本文介绍了使用Datastax Java驱动程序com.datastax.driver.core.exceptions.InvalidQueryException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是通过CLI这样创建列族的-

I created my column family like this from the 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'}
      ];

现在我正尝试使用Datastax Java驱动程序插入此列系列-

Now I was trying to insert into this column family using the Datastax Java driver-

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:
未配置的列家族配置文件

com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured columnfamily profile

通过这种方式,我试图使用Datastax Java驱动程序创建与Cassandra的连接/会话初始化-

And by this way, I am trying to create connection/session initialization to Cassandra using Datastax java driver-

private CassandraDatastaxConnection() {

    try{
    cluster = Cluster.builder().addContactPoint("localhost").build();
    session = cluster.connect("my_keyspace");           
    } catch (NoHostAvailableException e) {

            throw new RuntimeException(e);
    }
}

我正在运行Cassandra 1.2.3。而且我可以使用上面的代码连接到Cassandra。我面临的唯一问题是在插入时。

I am running Cassandra 1.2.3. And I am able to connect to Cassandra using the above code. The only problem I am facing is while inserting.

我想知道的事情是,是否可以使用以下命令插入列族(我是从CLI模式创建的) Datastax Java驱动程序吗?当我尝试插入以CLI模式创建的Column Family时,总是会遇到上述异常。

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? As soon as I am trying to insert into Column Family which I have created in CLI mode, I always get the above exception.

但是如果我尝试插入另一个表中我已经在 CQLsh模式中创建的文件,可以插入其中。

But If I try to insert into another table that I have created in CQLsh mode, I am able to insert into that.

任何帮助将不胜感激。

Any help will be appreciated.

推荐答案

我的猜测:您的CLI列族位于不同的键空间中。

My guess: your CLI columnfamilies are in a different keyspace.

这篇关于使用Datastax Java驱动程序com.datastax.driver.core.exceptions.InvalidQueryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆