Package com.mongodb
Class CommandResult
java.lang.Object
java.util.AbstractMap<K,V>
 
java.util.HashMap<K,V>
 
java.util.LinkedHashMap<String,Object>
 
org.bson.BasicBSONObject
com.mongodb.BasicDBObject
com.mongodb.CommandResult
- All Implemented Interfaces:
- DBObject,- Serializable,- Cloneable,- Map<String,,- Object> - BSONObject,- Bson
A simple wrapper to hold the result of a command.  All the fields from the response document have been added to this result.
- See Also:
- MongoDB documentation
- Database Commands
- 
Nested Class SummaryNested classes/interfaces inherited from class java.util.AbstractMapAbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> 
- 
Field SummaryFields inherited from interface org.bson.conversions.BsonDEFAULT_CODEC_REGISTRY
- 
Method SummaryModifier and TypeMethodDescriptionGets the error message associated with a failed command.Utility method to create an exception from a failed command.booleanok()Gets the "ok" field, which is whether this command executed correctly or not.voidThrows aCommandFailureExceptionif the command failed.Methods inherited from class com.mongodb.BasicDBObjectappend, copy, equals, hashCode, isPartialObject, markAsPartialObject, parse, parse, toBsonDocument, toJson, toJson, toJson, toJson, toStringMethods inherited from class org.bson.BasicBSONObjectcontainsField, get, getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getInt, getInt, getLong, getLong, getObjectId, getObjectId, getString, getString, putAll, putAll, removeField, toMapMethods inherited from class java.util.LinkedHashMapclear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesMethods inherited from class java.util.HashMapclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bson.conversions.BsontoBsonDocumentMethods inherited from interface org.bson.BSONObjectcontainsField, get, keySet, put, putAll, putAll, removeField, toMapMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putIfAbsent, remove, remove, replace, replace, size
- 
Method Details- 
okpublic boolean ok()Gets the "ok" field, which is whether this command executed correctly or not.- Returns:
- true if the command executed without error.
 
- 
getErrorMessageGets the error message associated with a failed command.- Returns:
- The error message or null
 
- 
getExceptionUtility method to create an exception from a failed command.- Returns:
- The mongo exception, or null if the command was successful.
 
- 
throwOnErrorpublic void throwOnError()Throws aCommandFailureExceptionif the command failed. Otherwise, returns normally.- Throws:
- MongoException- with the exception from the failed command
- See Also:
 
 
-