1

使用 CQL JDBC 驱动程序 (cassandra-jdbc-1.1.2) 连接到 Apache Cassandra 数据库时出现以下错误。仅当我尝试执行 UPDATE 语句时才收到错误消息,SELECT 工作正常。我也可以使用 cqlsh 连接到 cassandra。

java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException
    at org.apache.cassandra.cql.jdbc.CassandraStatement.doExecute(CassandraStatement.java:195)
    at org.apache.cassandra.cql.jdbc.CassandraStatement.execute(CassandraStatement.java:203)
    at com.concordusa.complete.dao.cassandra.keygen.MessageKeyGenerator.updateHighKeyInDatabase(MessageKeyGenerator.java:69)
    at com.concordusa.complete.dao.cassandra.keygen.MessageKeyGenerator.getNextHighKeyValue(MessageKeyGenerator.java:44)
    at com.concordusa.complete.dao.cassandra.keygen.MessageKeyGenerator.getKey(MessageKeyGenerator.java:30)
    at com.concordusa.complete.dao.cassandra.keygen.MessageKeyGenerator.main(MessageKeyGenerator.java:85)
Caused by: org.apache.thrift.transport.TTransportException
    at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
    at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:129)
    at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql_query(Cassandra.java:1402)
    at org.apache.cassandra.thrift.Cassandra$Client.execute_cql_query(Cassandra.java:1388)
    at org.apache.cassandra.cql.jdbc.CassandraConnection.execute(CassandraConnection.java:397)
    at org.apache.cassandra.cql.jdbc.CassandraConnection.execute(CassandraConnection.java:421)
    at org.apache.cassandra.cql.jdbc.CassandraStatement.doExecute(CassandraStatement.java:161)
    ... 5 more

我在使用 cassandra 1.0.7 时没有遇到这个问题。我将 cassandra 更新为 1.1.6,因为 1.1.* 之前的版本不支持准备好的语句。

提前致谢!

编辑:这是我在服务器日志中的内容:

    ERROR [Thrift:13] 2012-10-23 14:50:24,327 CustomTThreadPoolServer.java (line 204) Error occurred during processing of message.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at org.apache.cassandra.cql.Term.getByteBuffer(Term.java:102)
    at org.apache.cassandra.cql.UpdateStatement.mutationForKey(UpdateStatement.java:206)
    at org.apache.cassandra.cql.UpdateStatement.prepareRowMutations(UpdateStatement.java:166)
    at org.apache.cassandra.cql.UpdateStatement.prepareRowMutations(UpdateStatement.java:130)
    at org.apache.cassandra.cql.QueryProcessor.batchUpdate(QueryProcessor.java:256)
    at org.apache.cassandra.cql.QueryProcessor.processStatement(QueryProcessor.java:596)
    at org.apache.cassandra.cql.QueryProcessor.process(QueryProcessor.java:879)
    at org.apache.cassandra.thrift.CassandraServer.execute_cql_query(CassandraServer.java:1240)
    at org.apache.cassandra.thrift.Cassandra$Processor$execute_cql_query.getResult(Cassandra.java:3542)
    at org.apache.cassandra.thrift.Cassandra$Processor$execute_cql_query.getResult(Cassandra.java:3530)
    at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:32)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:34)
    at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:186)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
4

2 回答 2

0

看来我的问题是胡说八道。这是我的代码:

PreparedStatement stmt = con.prepareStatement(query);
stmt.setLong(1, key);
stmt.execute(query);

query是(显然)字符串。解决问题的方法是querystmt.execute(query)

我仍然不确定execute()在这种情况下的行为是否正确。

于 2012-10-23T14:30:02.643 回答
0

这是 jdbc 驱动程序 https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/issues/detail?id=95中的一个开放错误, 它在连接时命中,而不是在查询时命中

于 2014-03-14T08:09:02.607 回答