MongoDB 3.2.1 Java BasicDBObjectBuilder <p>I am getting the following Error when I tried to insert BasicDBObjectBuilder into collection</p> <blockquote> <p>Caused by: java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to com.mongodb.BasicDBObjectBuilder</p> </blockquote> <pre><code> MongoClient mongo = new MongoClient( "xxx.xxx.x.x" , 27017 ); MongoDatabase db = mongo.getDatabase("hello"); //create database MongoCollection&lt;BasicDBObjectBuilder&gt; collbuild = db.getCollection("newcoll", BasicDBObjectBuilder.class); BasicDBObjectBuilder collbuilder = BasicDBObjectBuilder.start() .add("name","joe") .add("dob", "12/12/12") .add("country", "Utopia"); collbuild.insertOne((BasicDBObjectBuilder) collbuilder.get()); // passing BasicDBObjectBuilder into a BasicDBObjectBuilder collection? </code></pre> <p>I thought I am passing the BasicDBObjectBuilder into a BasicDBObjectBuilder collection. I know how to use BasicDBObject but I want to try this method because I am new to programming. So can someone clarify?</p> <blockquote> <p>UPDATED</p> </blockquote> <p>It seems I was trying to to use insertOne which is a BasicDBObject function. So what is needed to pass the BasicDBObjectBuilder into a BasicDBObjectBuilder collection?</p>