My question is - How can I insert String value in blob data type? Here record_value is blob data type and I am having string value in it.
Exception in thread "main" com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [blob <-> java.lang.String]
Here's my code (comments removed for brevity):
BatchStatement batchStatement = new BatchStatement();
Insert insert = QueryBuilder
.insertInto("detail_metadata_by_comm_uuid_stage_code")
.value("comm_uuid", bindMarker())
.value("processing_stage_code", bindMarker())
.value("feeder_system_message_dropoff_timestamp", bindMarker())
.value("key_id", bindMarker())
.value("details_payload", bindMarker()); // this is the DataStax Cassandra blob column
PreparedStatement detail_metadata_by_comm_uuid_stage_code_insert_ps = session.prepare(insert.toString());
BoundStatement boundStmt = detail_metadata_by_comm_uuid_stage_code_insert_ps.bind
(
comm_uuid,
processing_stage_code,
feeder_system_message_dropoff_timestamp,
key_id,
Bytes.toHexString (
details_payload.getBytes(Charset.forName("UTF-8"))
// details_payload is of type String
)
);
batchStatement.add(boundStmt);
session.execute(batchStatement);
Thoughts?
Bytes.toHexString(details_payload.getBytes(Charset.forName("UTF-8"))
ByteBuffer.wrap(details_payload.getBytes(Charset.forName("UTF-8"))