June 24th, 2013

I just wrote my first small Java application to use the DataStax Java Driver to connect to a Cassandra 1.2 cluster and write a table, using CQL3, and write a row of data into that table, which row contained two Blobs. Boy am I happy!

Here is how I did it:

0. I used the cqlsh to make a keyspace named audiofile.

1. I wrote a small Service containing one CassandraDAO.

2. I wrote a PlaylistDAO to extend a base CassandraDAO.

3. I wrote an AudioFile POJO entity class which implements a simple CassandraEntity interface, and populated it with real data.

4. I invoked the methods on the PlaylistDAO from the PlaylistService, passing over the populated AudioFile POJO.

5. I went back to

and did a

and boom! there it was. The two Blobs (one for the JPEG cover art, and one for the actual audio file were represented as 0x0000… (lots of zeros).

Here is the code: