title: How to retrieve only one column from collection in mongodb using java?
body: <p>I want to retrieve only ID column with value less than 4,</p>
  
  <pre><code>MongoDatabase database = client.getDatabase("d");
  
       MongoCollection&lt;org.bson.Document&gt; contCol = database.getCollection("test");
       BasicDBObject query = new BasicDBObject();
       query.put("ID",1);
  
   FindIterable&lt;org.bson.Document&gt; it = contCol.find().projection(excludeId());
  </code></pre>
  
  <p>Doesn't give me the required output. The collection <em>test</em> has two columns, namely <em>ID</em> and <em>name</em>; the query is returning both the columns, I want to get only the <em>ID</em> column.</p>