使用CQL JDBC驱动程序(cassandra-jdbc-1.1.2)连接到Apache Cassandra数据库时出现以下错误。我只是在尝试执行UPDATE语句时才收到错误,SELECTs工作正常。我也可以使用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)
答案 0 :(得分:0)
似乎我的问题不存在。这是我的代码:
PreparedStatement stmt = con.prepareStatement(query);
stmt.setLong(1, key);
stmt.execute(query);
query
(obiously)String。解决问题的方法是从query
stmt.execute(query)
我仍然不确定execute()
在这种情况下的行为是否正确。
答案 1 :(得分:0)
这是jdbc驱动程序中的一个漏洞 https://code.google.com/a/apache-extras.org/p/cassandra-jdbc/issues/detail?id=95 它点击连接,而不是查询