2016-01-21 71 views
-3

有沒有什麼辦法可以像這樣在Java中執行Mongo查詢?與Java一起使用的MongoDB查詢

client.execute("db.name.find({'age':'20'})"); 
+1

閱讀本文http://mongodb.github.io/mongo-java-driver/2.13/getting-started/quick-tour/ – zombie

回答

0

不行,你必須做這樣的:

db.getCollection("name").find(new Document("age", "20")); 

的驅動程序使用到的mongod服務器的直接連接,而不是執行shell命令。