java-8cassandracassandra-3.0datastax-java-driverbind-variables

Cassandra select query with Bind Variables in java8


I am trying to execute a Cassandra query in Java8. My query is SELECT * FROM customer where aor='north' and I execute it with session.execute(query) and got correct answer. But then I changed my query to SELECT * FROM customer where aor=?

PreparedStatement statement =  session.prepare(query);
BoundStatement boundStatement = statement.bind("'north'");
ResultSet results = session.execute(boundStatement);
for (Row row : results) {
            System.out.println(row.toString());
        } 

This is not working. No errors showing but I am not getting any result.

Can someone please help


Solution

  • When you are using statement.bind("'north'"); it means that you want literally find 'north'.

    Just change your string to north and it will work as you wanted