Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19416

Executing "dbStats" fails: "exception: need a valid database name" (3.0 Server, 2.13 Java driver)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.4
    • Component/s: Diagnostics
    • Labels:
      None
    • Windows
    • Hide
      Mongo mongo = new MongoClient();
      DB db = mongo.getDB("TestDB"); // TestDB exists
      BasicDBObject dbStats = new BasicDBObject("dbStats", "1");
      dbStats.put("scale", 1);
      CommandResult command = db.command(dbStats);
      if (!command.ok()) {
      	throw command.getException();
      }
      

      Output:

      com.mongodb.CommandFailureException: { "serverUsed" : "127.0.0.1:27017" , "errmsg" : "exception: need a valid database name" , "code" : 28539 , "ok" : 0.0}
      
      Show
      Mongo mongo = new MongoClient(); DB db = mongo.getDB( "TestDB" ); // TestDB exists BasicDBObject dbStats = new BasicDBObject( "dbStats" , "1" ); dbStats.put( "scale" , 1); CommandResult command = db.command(dbStats); if (!command.ok()) { throw command.getException(); } Output: com.mongodb.CommandFailureException: { "serverUsed" : "127.0.0.1:27017" , "errmsg" : "exception: need a valid database name" , "code" : 28539 , "ok" : 0.0}

      The combination mongo-java-driver-2.13.2 & MongoDB server 3.0.2/3.0.4 causes the dbStats command to fail:

      com.mongodb.CommandFailureException:

      { "serverUsed" : "127.0.0.1:27017" , "errmsg" : "exception: need a valid database name" , "code" : 28539 , "ok" : 0.0}

      END

      The same code works for a MongoDB 2.x server using the same driver.

            Assignee:
            sam.kleinman Sam Kleinman (Inactive)
            Reporter:
            mango Jan S.
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: