title: mongodb java check if insert succeeded
body: <pre><code>MongoClient mongoClient = new MongoClient()
  DB db = mongoClient.getDB("mydb")
  DBCollection recordsColl = db.getCollection("records")
  BasicDBObject mongoRecord = new BasicDBObject()
  //put some things in mongoRecord
  recordsColl.insert(mongoRecord)
  </code></pre>
  
  <p>How can I tell if the insert went successfully?  Doing </p>
  
  <pre><code>WriteResult writeResult = recordsColl.insert(mongoRecord)
  writeResult.getLastError()
  </code></pre>
  
  <p>Seems <code>getLastError()</code> has depreciated.  Any suggestions?  Thanks!</p>