incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Techy Teck <>
Subject Retrieve data from Cassandra database using Datastax java driver
Date Sun, 21 Apr 2013 04:02:47 GMT
I am working with Datastax java-driver. And I am trying to retrieve few
columns from the database basis on the input that is being passed to the
below method-

public Map<String, String> getAttributes(final String userId, final
Collection<String> attributeNames) {

String query="SELECT " +attributeNames.toString().substring(1,
attributeNames.toString().length()-1)+ " from profile where id = '"+userId+

ResultSet result = CassandraDatastaxConnection.getSession().execute(query);

Map<String, String> attributes = new ConcurrentHashMap<String, String>();
 for(Definition def : result.getColumnDefinitions()) {
 //not sure how to put the columnName and columnValue that came back from
the database
attributes.put(column name, column value);
 return attributes;

Now I got the result back from the database in *result*
Now how to put the colum name and column value that came back from the
database in a map?

I am not able to understand how to retrieve colum value for a particular
column in datastax java driver?

Any thoughts will be of great help.

View raw message