title: MongoDB batch insert not working with java driver
body: <p>I am trying out mongoDB, here is the code I used to connect and insert records.</p>
  
  <pre><code>import com.mongodb.*;
  
  import java.net.UnknownHostException;
  import java.util.LinkedList;
  import java.util.List;
  
  public class MongoConnect {
  
      public static void main(String[] args) throws UnknownHostException, InterruptedException {
          MongoClient mongoClient = new MongoClient("localhost");
          DB db = mongoClient.getDB("mydb");
          DBCollection collection = db.getCollection("emails");
          long currentTime = System.currentTimeMillis();
  
          long totalRecords = 120L;
          long batchInsert = 0;
  
          long insertedRecords = 0L;
          List&lt;DBObject&gt; basicDBObjects = new LinkedList&lt;DBObject&gt;();
          while (insertedRecords &lt; totalRecords) {
              System.out.println("adding: "+insertedRecords);
  
              basicDBObjects.add(new BasicDBObject("email", "amar+" + insertedRecords + "@gmail.com"));
              insertedRecords++;
              batchInsert++;
              if (batchInsert == 5) {
                  System.out.println("inserting: "+(insertedRecords-5));
                  collection.insert(basicDBObjects);
  
                  System.out.println("Inserted: *******"+insertedRecords);
                  //Thread.sleep(200);
                  batchInsert = 0;
                  basicDBObjects = new LinkedList&lt;DBObject&gt;();
              }
          }
  
          long endTime = System.currentTimeMillis();
          System.out.println("Total time taken :"+((endTime-currentTime)/1000));
          //long currentTime = System.currentTimeMillis();
          DBCursor email = collection.find(new BasicDBObject("email", "amar+3@gmail.com"));
          int count = email.count();
          System.out.println("count = "+count);
          System.out.println("Total time taken: "+String.valueOf(System.currentTimeMillis()-currentTime));
  
      }
  }
  </code></pre>
  
  <p>I can see the collection with "emails" is created it is shown as part of <code>show collections</code>
  But when I do <code>db.mydb.emails.find({})</code> no result is coming up. I tried re-starting mongo service and even tried <code>db.dropDatabase()</code> nothing seems to work. Can anyone point out the issue? FYI inserts over console are working fine.</p>