[英]com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table user"
[英]Query fails with “com.datastax.driver.core.exceptions.InvalidQueryException: String didn't validate.”
我有一個這樣創建的表:
CREATE TABLE messages (
stream int,
sequence int,
timestamp bigint,
message blob,
PRIMARY KEY (stream, sequence)
) WITH gc_grace_seconds = 0;
在CQLSH中運行以下查詢非常正常:
select * from messages where stream = 1 and sequence >= 1 and sequence <= 100;
但是,當我嘗試通過Java驅動程序運行相同代碼時,出現以下異常:
com.datastax.driver.core.exceptions.InvalidQueryException: String didn't validate.
at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:35)
at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException(ResultSetFuture.java:271)
at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture.java:187)
at com.datastax.driver.core.Session.execute(Session.java:126)
at com.datastax.driver.core.Session.execute(Session.java:100)
我正在使用參數化查詢API:
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);
將stream
和sequence
字段定義為UUID
類型
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.