Apologies, this seems to be addressed in the thread :
https://groups.google.com/a/lists.datastax.com/forum/#!searchin/java-driver-user/blob$20ByteBuffer/java-driver-user/4_KegVX0teo/2OOZ8YOwtBcJ Andy On 19 Mar 2014, at 11:55, Andrew Cobley <a.e.cob...@dundee.ac.uk<mailto:a.e.cob...@dundee.ac.uk>> wrote: Cassandra 2.0.4 I’m using blobs to save and retrieve images in cassanda. However the blob I get back is not the blob I saved ! I’m saving to CQL like this: byte[] b= {(byte)10,(byte)20,(byte)30}; int length=b.length; ByteBuffer buffer =ByteBuffer.wrap(b); Session session = cluster.connect("keyspace2"); PreparedStatement ps = session.prepare("insert into tweets ( image, user, interaction_time,imagelength) values(?,?,?,?)"); BoundStatement boundStatement = new BoundStatement(ps); session.execute( boundStatement.bind( buffer, "majed", convertor.getTimeUUID(),length)); and retrieving like this: Session session = cluster.connect("keyspace2"); PreparedStatement ps = session.prepare("select image,user,imagelength from tweets where user =?"); BoundStatement boundStatement = new BoundStatement(ps); ResultSet rs =session.execute(boundStatement.bind( "majed")); ByteBuffer bImage=null; for (Row row : rs) { bImage = row.getBytes("image") ; System.out.println ("Image "); for (int i=0; i< 40;i++){ System.out.print(String.format("%x ",bImage.get(i))); if ((i+1)%16 ==0) System.out.println(); } System.out.println(); } session.close(); So, I should be saving byte array of 3 long, and the buffer in the save section is correct. However when I run the retrieve section I’m getting back the following: 82 0 0 8 0 0 0 28 0 0 0 2 0 0 0 5 0 0 0 3 0 0 0 1 0 0 0 3 a 14 1e You can see the saved bytes are the last three and there is extra padding at the front. Worse if I change the Select statement to: PreparedStatement ps = session.prepare("select user,image,imagelength from tweets where user =?”); I get back: 82 0 0 8 0 0 0 28 0 0 0 2 0 0 0 5 0 0 0 3 0 0 0 1 0 0 0 5 6d 61 6a 65 64 0 0 0 3 a 14 1e If you look you can see the username “majed” in the returned blob (6d 61 6a 65 64). any ideas whats going on here ? Many thanks Andy The University of Dundee is a registered Scottish Charity, No: SC015096 The University of Dundee is a registered Scottish Charity, No: SC015096