Bilal
Bilal

Reputation: 122

Cassandra read Column

String cqlStatement = "SELECT * FROM local"; for (Row row : session.execute(cqlStatement)) { System.out.println(row.toString()); }

how to get each Column value from the selected row ?

Upvotes: 0

Views: 59

Answers (1)

kkmishra
kkmishra

Reputation: 709

If you are using cassandra ds-driver the following should work for you.

String cqlStatement = "SELECT * FROM local"; 
for (Row row : session.execute(cqlStatement))
        {
            row.getString("columnName"); // for string data type
//            row.getBool("columnName"); for boolean data type
//            row.getUUID("columnName"); for UUID type
//            row.getVarint("columnName"); for int type
//            row.getLong("columnName"); for long type
//            row.getDate("columnName"); for date type
//            row.getBytes("columnName"); for bytes/anonymous type
        }

Upvotes: 2

Related Questions