1

我正在使用 DataStax java 驱动程序进行 CQL 表数据插入、更新。我的问题是我如何知道更新查询已通过ResultSet.Following 成功更新。以下代码正在更新表中的记录。

    PreparedStatement statement = session.prepare(query);
    BoundStatement bs = new BoundStatement(statement);
    ResultSet resultSet = session.execute(bs.bind(key));
4

2 回答 2

2

I highly advice not to enable tracing in production and use its results in your code as a verification. In cassandra world in general, if your update/insert call does not throw an exception, your update was successful. Whether or not your updated reflected in all replicas is another question. You should your C*'s tunable consistency and use higher consistency levels in your calls if you want more consistency.

于 2014-02-04T19:43:49.360 回答
1

通常,您将无法获取信息,但您仍然可以通过 跟踪它enable tracing,它可以提供有关该操作的更多信息。

  ResultSet results = session.execute(query);
  ExecutionInfo executionInfo = results.getExecutionInfo();
  QueryTrace queryTrace = executionInfo.getQueryTrace();

有关详细信息,建议您阅读有关跟踪的此文档。

于 2014-02-04T19:38:43.650 回答