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
public class CommandResult
- extends BasicDBObject
A simple wrapper for the result of getLastError() calls and other commands
- See Also:
- Serialized Form
Methods inherited from class org.bson.BasicBSONObject |
containsField, containsKey, equals, get, getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getInt, getInt, getLong, getLong, getObjectId, getObjectId, getString, getString, put, putAll, putAll, removeField, toMap |
ok
public boolean ok()
- gets the "ok" field which is the result of the command
- Returns:
- True if ok
getErrorMessage
public String getErrorMessage()
- gets the "errmsg" field which holds the error message
- Returns:
- The error message or null
getException
public MongoException getException()
- utility method to create an exception with the command name
- Returns:
- The mongo exception or null
throwOnError
public void throwOnError()
- throws an exception containing the cmd name, in case the command failed, or the "err/code" information
- Throws:
MongoException
getServerUsed
public ServerAddress getServerUsed()