I want to execute soem admin command with parameters from java.
The commands are:
{ enablesharding : \"test\" }
{ shardcollection : \"test.test_coll
I just want to add that Julias's answer is correct, but now it's deprecated.
You could use new API (Document
class is from package org.bson
):
MongoDatabase database = client.getDatabase("admin");
Document documentA = database.runCommand(new Document("enablesharding", "test"));
Document documentB = database.runCommand(
new Document("shardcollection", "testDB.x").append("key", new Document("userId", 1)));