Questions tagged [datastax-java-driver]

A Java client driver for Apache Cassandra. This driver works exclusively with the Cassandra Query Language version 3 (CQL3) and Cassandra's binary protocol.

The DataStax Java driver for Apache Cassandra is the de-facto standard for connecting to a Cassandra cluster from a Java application. Can be used to connect to:

  • Apache Cassandra
  • DataStax Enterprise (DSE)
  • DataStax Astra DB

Support and documentation: https://docs.datastax.com/en/developer/java-driver/latest/

997 questions
65
votes
3 answers

How to get current timestamp with CQL while using Command Line?

I am trying to insert into my CQL table from the command line. I am able to insert everything. But I am wondering if I have a timestamp column, then how can I insert into timestamp column from the command line? Basically, I want to insert current…
user2467545
27
votes
11 answers

Error while connecting to Cassandra using Java Driver for Apache Cassandra 1.0 from com.example.cassandra

While connecting to Cassandra client using java driver for Cannsandra by DataStax, it is throwing following error.. Exception in thread "main" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried:…
Saurabh Deshpande
  • 1,153
  • 4
  • 18
  • 35
20
votes
3 answers

Prepared Statement with collection in IN clause in Datastax Cassandra CQL driver

I am trying to run the following query SELECT edge_id, b_id FROM booking_by_edge WHERE edge_id IN ? I bind Java list of Long's as a parameter and I get an exception SyntaxError: line 0:-1 mismatched input '' expecting ')'…
i.petruk
  • 1,276
  • 1
  • 13
  • 18
19
votes
5 answers

Can't connect to cassandra - NoHostAvailableException

I know there are several threads about the NoHostAvailableException but they simply don't provide a solution to my problem. I can't connect to Cassandra with the Datastax Java Cassandra Driver. I get the…
user2280013
  • 191
  • 1
  • 1
  • 4
18
votes
2 answers

How to throttle writes request to cassandra when working with "executeAsync"?

I am using datastax java driver 3.1.0 to connect to cassandra cluster and my cassandra cluster version is 2.0.10. I am writing asynchronously with QUORUM consistency. private final ExecutorService executorService =…
john
  • 11,311
  • 40
  • 131
  • 251
18
votes
2 answers

CQL3: How to retrieve the TTL when there is only a primary key?

I have a CQL table defined like this: CREATE table primary_key_only( row_key varchar, clustered_key varchar, primary key(row_key, clustered_key) ) Assuming I insert values like this: INSERT INTO primary_key_only (row_key, clustered_key)…
Peter
  • 6,354
  • 1
  • 31
  • 29
17
votes
1 answer

Cassandra Java Driver- QueryBuilder API vs PreparedStatements

Datastax Java driver (cassandra-driver-core 2.0.2) for Cassandra supports PreparedStatements as well as QueryBuilder API. Any specific advantages using one over the other? Disadvantages? Documentation:…
16
votes
5 answers

New Cassandra project - Astyanax or Java Driver?

I'm starting a new project with Cassandra (and plan to use the latest stable (1.2.x) version). I have tried several different Java libraries, like Hector, Astyanax, Cassandra-jdbc... Among them, (in short) my choice is Astyanax. But then I also…
su-
  • 3,116
  • 3
  • 32
  • 42
14
votes
1 answer

How to get tombstone count for a cql query?

I am trying to evaluate number of tombstones getting created in one of tables in our application. For that I am trying to use nodetool cfstats. Here is how I am doing it: create table demo.test(a int, b int, c int, primary key (a)); insert into…
Prasanth
  • 1,005
  • 5
  • 19
  • 39
14
votes
4 answers

Re-using PreparedStatement when using Datastax Cassandra Driver?

I'm currently using the Datastax Cassandra driver for Cassandra 2 to execute cql3. This works correctly. I started using PreparedStatement's: Session session = sessionProvider.getSession(); try { PreparedStatement ps = session.prepare(cql); …
TinusSky
  • 1,657
  • 5
  • 24
  • 32
14
votes
3 answers

Cassandra Datastax Driver - Connection Pool

I'm trying to understand the connection pooling in Datastax Cassandra Driver, so I can better use it in my web service. I have version 1.0 of the documentation. It says: The Java driver uses connections asynchronously, so multiple requests can be…
Anakin001
  • 1,226
  • 2
  • 14
  • 30
13
votes
1 answer

What are the implications of using lightweight transactions?

In particular I was looking at this page where it says: If lightweight transactions are used to write to a row within a partition, only lightweight transactions for both read and write operations should be used. I'm confused as to what using LWTs…
OrangeDog
  • 36,653
  • 12
  • 122
  • 207
12
votes
1 answer

How to add multiple columns in cassandra table?

I need to add some new columns to my existing column_family/table in cassandra. I can add single column like this : ALTER TABLE keyspace_name.table_name ADD column_name cql_type; Can I add all new columns using a single query? If yes, how to do it…
Pankaj Goyal
  • 1,448
  • 3
  • 15
  • 25
12
votes
2 answers

Passing parameter to Cassandra CQL query using DataStax client

I am using datastax as a client for connecting to cassandra. I have successfully connected to cassandra cluster/keyspace/column families through Java. I am trying, firing some queries on cassandra column family thriugh java. For me it is working for…
Saurabh Deshpande
  • 1,153
  • 4
  • 18
  • 35
11
votes
2 answers

Cassandra : Batch write optimisation

I get bulk write request for let say some 20 keys from client. I can either write them to C* in one batch or write them individually in async way and wait on future to get them completed. Writing in batch does not seem to be a goo option as per…
Peter
  • 2,719
  • 4
  • 25
  • 55
1
2 3
66 67