userimage

how to use QueryBuilder in cassandra database using java code?

i want a detail explanation about QueryBuilder of cassandra java driver api. Thanks in advance.
userimage
Moe
Using QueryBuilder we can generate the query for execution in cassandra database via java code.

for example we want to query for getting all the records from database. we can use below process:
Statement statement = QueryBuilder.select().all().from("kayspacename", "tablename");
ResultSet rs = session.execute(statement).all();


If we want add specific column that we want to retrive based on where clause:

Statement statement = QueryBuilder.select("col1", "col2").from("keyspacename", "tablename")
        .where(QueryBuilder.eq("prim1", prim1)).and(QueryBuilder.eq("prime2", prime2));
ResultSet resultSet = DBConnection.CLUSTER.newSession().execute(statement);
Answer is