Java Driver 2.1 reading counter values from row

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Java Driver 2.1 reading counter values from row

Amila Paranawithana
in Apache Cassandra Java Driver 2.1 how to read counter type values from a row when iterating over result set.

eg: If I have a counter table called 'countertable' with key and a counter colum 'sum' how can I read the value of the counter column using Java driver?
If I say, row.getInt("sum") this gives the following error,

com.datastax.driver.core.exceptions.InvalidTypeException: Value sum is of type counter

Code ::
ResultSet results = session.execute("SELECT * FROM simplex.countertable ") 
for (Row row : results) {
    System.out.println(row.getString("key"),row.getInt("sum")));
}

Thanks,
Amila

--

Amila Iroshani Paranawithana , Senior Software Engineer , AdroitLogic
| ☎: +94779747398
| ✍: http://amilaparanawithana.blogspot.com

Facebook Twitter LinkedIn Skype amila.paranawithana
Reply | Threaded
Open this post in threaded view
|

Re: Java Driver 2.1 reading counter values from row

Amila Paranawithana
Hi All,

This is possible with cassandra-driver-core-2.1.5, with 'row.getLong("sum")'.

Thanks

On Fri, Mar 27, 2015 at 2:51 PM, Amila Paranawithana <[hidden email]> wrote:
in Apache Cassandra Java Driver 2.1 how to read counter type values from a row when iterating over result set.

eg: If I have a counter table called 'countertable' with key and a counter colum 'sum' how can I read the value of the counter column using Java driver?
If I say, row.getInt("sum") this gives the following error,

com.datastax.driver.core.exceptions.InvalidTypeException: Value sum is of type counter

Code ::
ResultSet results = session.execute("SELECT * FROM simplex.countertable ") 
for (Row row : results) {
    System.out.println(row.getString("key"),row.getInt("sum")));
}

Thanks,
Amila

--

Amila Iroshani Paranawithana , Senior Software Engineer , AdroitLogic
| ☎: <a href="tel:%2B94779747398" value="+94779747398" target="_blank">+94779747398
| ✍: http://amilaparanawithana.blogspot.com

Facebook Twitter LinkedIn Skype amila.paranawithana



--

Amila Iroshani Paranawithana , Senior Software Engineer , AdroitLogic
| ☎: +94779747398
| ✍: http://amilaparanawithana.blogspot.com

Facebook Twitter LinkedIn Skype amila.paranawithana