File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
source/includes/usage-examples/code-snippets Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 4
4
import org .bson .BsonInt64 ;
5
5
import org .bson .Document ;
6
6
7
- import com .mongodb .ConnectionString ;
8
- import com .mongodb .MongoClientSettings ;
9
7
import com .mongodb .MongoException ;
10
8
import com .mongodb .client .MongoClient ;
11
9
import com .mongodb .client .MongoClients ;
12
10
import com .mongodb .client .MongoDatabase ;
11
+ import org .bson .conversions .Bson ;
13
12
14
13
15
14
public class RunCommand {
@@ -24,8 +23,12 @@ public static void main(String[] args) {
24
23
try {
25
24
Bson command = new BsonDocument ("dbStats" , new BsonInt64 (1 ));
26
25
Document commandResult = database .runCommand (command );
26
+
27
+ // Prints the database statistics
27
28
System .out .println ("dbStats: " + commandResult .toJson ());
29
+
28
30
} catch (MongoException me ) {
31
+ // Prints a message if any exceptions occur during the command execution
29
32
System .err .println ("An error occurred: " + me );
30
33
}
31
34
}
You can’t perform that action at this time.
0 commit comments