Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cassandra 查询失败,出现“com.datastax.driver.core.exceptions.InvalidQueryException:字符串未验证。”_Cassandra - Fatal编程技术网

Cassandra 查询失败,出现“com.datastax.driver.core.exceptions.InvalidQueryException:字符串未验证。”

Cassandra 查询失败,出现“com.datastax.driver.core.exceptions.InvalidQueryException:字符串未验证。”,cassandra,Cassandra,我创建了一个如下表: CREATE TABLE messages ( stream int, sequence int, timestamp bigint, message blob, PRIMARY KEY (stream, sequence) ) WITH gc_grace_seconds = 0; 在CQLSH中运行以下查询效果非常好: 从消息中选择*,其中stream=1,sequence>=1,sequence是否尝试添加;在查询结束时,请执行以下操作: public final S

我创建了一个如下表:

CREATE TABLE messages (
stream int,
sequence int,
timestamp bigint,
message blob,
PRIMARY KEY (stream, sequence)
) WITH gc_grace_seconds = 0;
在CQLSH中运行以下查询效果非常好:


从消息中选择*,其中stream=1,sequence>=1,sequence是否尝试添加;在查询结束时,请执行以下操作:

public final String FETCH_CQL = "select stream, sequence, timestamp, message "
            + "from messages where stream = ? and sequence >= ? and sequence <= ?**;**";

将stream和sequence字段定义为类型UUID

Try PreparedStatement,我在答案中添加了示例代码。问题与使用int作为键和搜索条件的一部分有关。我已将此字段更改为“文本”,现在一切正常。这让人想起旧的Cassandra 1.x错误,由于节俭限制,使用非UTF8键插入失败。我猜这是密切相关的。
public final String FETCH_CQL = "select stream, sequence, timestamp, message "
            + "from messages where stream = ? and sequence >= ? and sequence <= ?";

session.execute(FETCH_CQL, Integer.parseInt(stream), Integer.parseInt(fromSequence), Integer.parseInt(toSequence));
public final String FETCH_CQL = "select stream, sequence, timestamp, message "
            + "from messages where stream = ? and sequence >= ? and sequence <= ?**;**";
PreparedStatement FETCH_PS = session.prepare(FETCH_CQL);
BoundStatement boundStatement = FETCH_PS.bind(Integer.parseInt(stream), Integer.parseInt(fromSequence), Integer.parseInt(toSequence));
session.execute(boundStatement);