Db2データベースから JSON ドキュメントを選択します。
多重定義 DBCollection.find() メソッドのいずれか 1 つを使用して、ドキュメントを選択できます。
Java™ プログラムの次のコードは、JSON ドキュメントの選択方法を示しています
DBCollection empColl = db.getCollection("employees");
//Looking for employees that are named 'Joe'
DBCursor cursor = empColl.find(new BasicDBObject("name", "Joe"));
try{
while(cursor.hasNext()){
DBObject obj = cursor.next();
doSomething(obj);
}
}finally{
//Close the cursor no matter what
cursor.close();
}以下に、多重定義
DBCollection.find() メソッドの例をいくつか示します。DBCollection.find(com.ibm.nosql.json.api.DBObject query)
DBCollection.find(com.ibm.nosql.json.api.DBObject query, DBObject fields)
DBCollection.find(com.ibm.nosql.json.api.DBObject, com.ibm.nosql.json.api.DBObject, int, int)
DBCollection.findOne(com.ibm.nosql.json.api.DBObject)特定の照会出力を取得するには、以下のメソッドの使用を検討してください。
DBCursor.sort(com.ibm.nosql.json.api.DBObject)
DBCursor.limit(int)
DBCursor.skip(int)