public void
testFindAll() throws UnknownHostException, MongoException {
// TODO
Auto-generated method stub
ArrayList<ServerAddress>
addrs = new ArrayList<ServerAddress>();
addrs.add(new
ServerAddress("192.168.1.101", 27017));
addrs.add(new
ServerAddress("192.168.1.102", 27017));
addrs.add(new
ServerAddress("192.168.1.103", 27017));
Mongo connection = new
Mongo(addrs);
DB
mongoJUnit = connection.getDB("deptDB");
DBCollection
dept = mongoJUnit.getCollection("deptJUnit");
DBCursor
cur = dept.find();
int index =
1;
for (
Iterator<DBObject> it = cur.iterator(); it.hasNext(); ++index) {
DBObject
obj = it.next();
System.out.println("data("+ index+"):"+obj.toString());
}
System.out.println(connection.getAddress());
}
'Brain Trainning > NoSQL' 카테고리의 다른 글
[NOSQL] 101 Questions To Ask When Considering A NoSQL Database (펌글) (0) | 2011.06.17 |
---|---|
[MongoDB] Auto Increment with MongoDB (0) | 2011.04.04 |
[MongoDB] 트위터 Collections... (0) | 2011.03.31 |
[MongoDB] Config 파일 옵션 (0) | 2011.03.09 |
[MongoDB] Java Code Sample (0) | 2011.02.28 |