在列中插入一些字段后,我试图用额外的值更新数据类表,如果我想在同一列中插入详细信息,它不工作,它进入第二行,谁能帮助我,我想要这个答案尽快
问问题
87 次
2 回答
1
这就是我通过获取特定列值位置来更新 bluemix 中的行的方式。这是代码。
这是从 bluemix 表中获取全部值的代码:
IBMQuery<Company> query = IBMQuery.queryForClass(Company.CLASS_NAME);
query.find().continueWith(new Continuation<List<Company>, Void>() {
public Void then(Task<List<Company>> task) throws Exception {
final List<Company> objects = task.getResult();
// Log if the find was cancelled.
if (task.isCancelled()) {
Log.e(CLASS_NAME, "Exception : Task " + task.toString()
+ " was cancelled.");
}
// Log error message, if the find task fails.
else if (task.isFaulted()) {
Log.e(CLASS_NAME, "Exception : "
+ task.getError().getMessage());
}
// If the result succeeds, load the list.
else {
companyList.clear();
for (IBMDataObject storeObject : objects) {
companyList.add((Company) storeObject);
}
if (task.isCompleted()) {
handler.sendEmptyMessage(2);
}
}
其中 Company 是表的名称,companyList 是公司类数组列表。
执行此代码后,companylist 将获取存储在 bluemix 中的所有行和列值,我们可以使用查询从中获取所需的行
query.whereKeyEqualsTo(User.RegisterName, userName);
query.whereKeyEqualsTo(User.Password, password);
其中 User 是表名 RegisterName 和 Password 是在用户类 userName 中定义的静态变量,password 是用户定义的给定输入。通过获取在 companyList 中检索到的所需行的位置,我按以下方式进行更新:
Company companyObject=Company.getPosition(position);
companyObject.setName("Something");
companyObject.save() query......
现在的问题是我能够正确地进行更新,但是我无法使用我在顶部提到的代码从 bluemix 检索表值。
于 2015-01-30T05:27:24.973 回答
0
// Find a set of objects by class
IBMQuery<Item> queryByClass = IBMQuery.queryForClass(Item.class);
// Find a specific object
IBMQuery<Item> queryForObject = myItem.getQuery();
query.find().continueWith(new Continuation<List<Item>, Void>() {
@Override
public Void then(Task<List<Item>> task) throws Exception {
if (task.isFaulted()) {
// Handle errors
} else {
// do more work
List<Item> objects = task.getResult();
}
return null;
}
});
于 2015-03-06T13:28:20.200 回答