- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我的笔记本电脑上运行着 Cassandra 1.2.11。我可以使用 nodetool
和 cqlsh
连接到它,但是当我尝试使用 DataStax 1.0.4 Java API 使用 CQL 3.0 进行连接时,出现以下错误:
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1 ([localhost/127.0.0.1] Unexpected error during transport initialization (com.datastax.driver.core.TransportException: [localhost/127.0.0.1] Channel has been closed)))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:186)
我正在使用以下代码进行连接,该代码取自 DataStax 文档。我已经尝试了几个端口号,包括离开 withPort()
调用,但似乎没有任何效果。
Cluster cluster = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9160)
.build();
使用 telnet
我可以验证 Cassandra 服务器确实正在监听我指定的每个端口。我还验证了所有必需的库 jar 文件都在我的类路径中,如文档中所述。
最佳答案
原来我错过了 documentation 中的一个部分.
我使用的是早期版本的 Cassandra 中的旧 cassandra.yaml
配置文件,它没有启用 Native Transport 二进制协议(protocol)。以下代码段显示了我需要更改的设置:
# Whether to start the native transport server.
start_native_transport: true
# port for the CQL native transport to listen for clients on
native_transport_port: 9042
重新启动 Cassandra 后,客户端能够成功连接并运行 CQL 3.0 命令。请注意,创建连接的代码必须更改为使用文件中指定的端口,如下所示:
Cluster cluster = new Cluster.Builder()
.addContactPoints("localhost")
.withPort(9042)
.build();
另外,请注意来自 Cassandra 1.2.5及以上版本,默认情况下启用 native 传输。
关于java - 使用 DataStax Java 驱动程序 1.0.4 通过 CQL 连接到 Cassandra 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20409470/
我想找到所有可以显式返回 null 的方法。 在 NDepend 中使用 CQL 这可能吗? 最佳答案 目前还不行,CQL 到目前为止还不知道变量、字段和返回值的值。 但是,建议使用以下默认规则。这个
在 CQL 脚本中使用时,有没有办法在 CQL 命令中传递变量,例如: select * from "Column Family Name" where "ColumnName"='A variabl
我遇到的问题是我想运行以下命令(但我不能): cqlsh < cql_directory/cql_create_stuff.cql 因为我还没有登录cqlsh。 所以我登录了: cqlsh -u 'm
我将内容存储在 CQL 的 map 中,我希望允许使用键删除该 map 中的特定内容。 key 是通过API从上面传入的,所以客户端可以传入任何它想要的东西。这是解释我的情况的代码片段...... f
我对 cassandra 很陌生,所以这听起来像是一个新手问题。 我正在运行 cqlsh 5.0.1 |本地的 Cassandra 2.1.4。 我有一张如下表: CREATE TABLE maste
CREATE TABLE users ( userID uuid, firstname text, lastname text, state text, zip int, age int, PRIMA
Cassandra的decimal数据类型对应的solr类型是什么? CREATE TABLE demo_table ( cost decimal ) solr对应的数据类型应该是什么? 最佳答案
我有一个像 创建表文件(id 文本主键、fname 文本、mimetype 文本、isdir bool 值、位置文本); 在文件(位置)上创建索引 file_location; 以下是表中的内容: 插
我有一个表,有一列 list类型(标签): CREATE TABLE "Videos" ( video_id UUID, title VARCHAR, tags LIST,
我有一个主键定义的列族,如下所示: ... PRIMARY KEY ((website_id, item_id), user_id, date) 将使用以下查询进行查询: SELECT * FROM
如何使用 Cassandra CQL 查询检查非主键字段的值是“A”还是“B”? (我使用的是 Cassandra 2.0.1) 这是表定义: CREATE TABLE my_table ( my
如果行键'row1'不存在,有什么方法可以防止CQL命令更新创建新行? UPDATE columnfamily SET data = 'test data' WHERE key = 'row1'; 最
我需要检查 Cassandra 数据库中是否存在某些键空间。我需要这样写: if (keyspace KEYSPACE_NAME not exists) create keyspace KEYSPAC
嗨,有什么办法可以在 Cassandra 中使用 CQL 使用 != 运算符吗? 我正在尝试在我的 columnfamily 上使用 != 运算符,但是当我尝试使用它时,它说: cqlsh:EPCCo
我有这张 table create table constants_values ( key_name_1 text,
我目前正在尝试将一个项目从 Cassandra 的 Thrift 界面(我越来越喜欢它)迁移到 CQL。我有以下困扰我的“问题”。我创建一个事件表: CREATE TABLE events ( e
如果我使用 cql 定义这样的表: CREATE TABLE scores ( name text, age int, score int, date timestamp, PRIMARY
如何在cassandra中编写子查询/嵌套查询。 CQL是否提供此功能? 我试过的示例: cqlsh:testdb> select itemname from item where itemid =
对于以下 Cassandra 架构: CREATE TABLE periods ( period_name text, event_name text, event_date timestamp, w
我可能想使用erlacassa Cassandra之间进行通信和 Eralng 。它是一个 CQL 客户端。所以我想知道,与thrift访问的cassandra相比,CQL(cassandra查询语言
我是一名优秀的程序员,十分优秀!