Alex Rivera | Logout

how to execute mongo admin command from java

Asked 2012-05-01T07:40:16.430
9

I want to execute soem admin command with parameters from java.

The commands are:

{ enablesharding : "test" }
{ shardcollection : "test.test_collection", key : {"number":1} }

How can I do it from java driver?

The following code doesn't works:

mongo.getDb("admin").command("{shardcollection : \"test.test_collection\", key:\"number\":1} }")
Edit
Report

1 Answer

-1

Have you ensured you have authenticated to the db successfully?

Have you tried db.eval(COMMAND_THAT_YOU_WANT_TO_EVAL);

answered 2012-05-01T07:52:42.937

Your Answer