Package com.mongodb

Class DuplicateKeyException

All Implemented Interfaces:
Serializable

public class DuplicateKeyException extends WriteConcernException
The legacy WriteConcernException, thrown when trying to insert or update a document containing a duplicate key.

Only thrown when using the legacy deprecated API, which is accessed via com.mongodb.MongoClient.getDB.

For application using the MongoCollection-based API, duplicate key exceptions can be determined via:

Since:
2.12
See Also:
  • Constructor Details

    • DuplicateKeyException

      public DuplicateKeyException(BsonDocument response, ServerAddress address, WriteConcernResult writeConcernResult)
      Construct an instance.
      Parameters:
      response - the response from the server
      address - the server address
      writeConcernResult - the write concern result