Sau*_*nde 12 java cql cassandra datastax-java-driver
我使用datastax作为连接cassandra的客户端.我已经通过Java成功连接到cassandra集群/密钥空间/列系列.我正在尝试,对cassandra专栏家族thriugh java发出一些疑问.对我来说,它适用于简单的查询
ResultSet results = session.execute("select * from demodb.customer where id = 1");
Run Code Online (Sandbox Code Playgroud)
现在我想从用户获取id参数并将其传递给session.execute(); 声明.我该怎么办呢?
Lyu*_*rov 18
下面是使用预准备语句插入有关图像的数据的代码示例.
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"));
Run Code Online (Sandbox Code Playgroud)
最近有两篇关于星球cassandra的博客文章,其中包含了驱动程序可以执行的操作的演示,它们包含代码示例,因此请查看它们:
| 归档时间: |
|
| 查看次数: |
12174 次 |
| 最近记录: |