下面是使用預處理語句插入圖像數據的代碼示例。
PreparedStatement statement = getSession().prepare(
"INSERT INTO pixelstore.image " +
"(image_name, " +
" upload_time, " +
" upload_by, " +
" file_type, " +
" file_size" +
") VALUES (?, ?, ?, ?, ?);");
// create the bound statement and initialise it with your prepared statement
BoundStatement boundStatement = new BoundStatement(statement);
session.execute(// this is where the query is executed
boundStatement.bind(// here you are binding the 'boundStatement'
"background", TimeUtil.getTimeUUID(), "lyubent", "png", "130527"));
已經有關於地球卡桑德拉最近兩次的博客文章有什麼樣的驅動程序可以做一個演示,它們包含的代碼示例,以便檢查出來:
- Materialized View with Cassandra and DataStax Java Driver
- Small Java Application using DataStax Java Driver and Cassandra 1.2 working
非常感謝你! –