title: mongodb with scala maven project
body: <p>I am stuck on an issue. I have created a scala maven project where I am trying to communicate with mongo. My project is getting build successfuly and I do not get any error when I execute my project, but still no data is getting inserted in my mongodb. </p>
  
  <p>If I insert data manually through mongo-cli then my code can read it but it is not even inserting a single record.
  Could you please help me in finding where I am making mistakes.
  My mongo version is 3.2.10 </p>
  
  <p>App.scala</p>
  
  <pre><code>package com.assignment.scala
  
  import org.mongodb.scala._
  import org.mongodb.scala.model.Aggregates._
  import org.mongodb.scala.model.Filters._
  import org.mongodb.scala.model.Projections._
  import org.mongodb.scala.model.Sorts._
  import org.mongodb.scala.model.Updates._
  import org.mongodb.scala.model._
  
  /**
   * @author ${user.name}
   */
  object App {
  
    def main(args: Array[String]) {
      println("Calling insertDoc==")
      insertDoc()
    }
  
    def insertDoc() = {
      val mongoClient = MongoClient()
      val database = mongoClient.getDatabase("assignment")
      val collection = database.getCollection("links")
  
     println("collection find : " + collection.find())
     collection.find().subscribe(
    (user: Document) =&gt; println("document------------"+user.toJson()),    
    (error: Throwable) =&gt; println(s"Query failed: ${error.getMessage}"),
    () =&gt; println("Done"))
  
      collection.drop()
  
      val bufferedSource = io.Source.fromFile("/home/impadmin/ServiceSource/ml-latest-small/links.csv")
      var firstLine = List[String]();
      var docList = List[Document]();
      for ((line,count) &lt;- bufferedSource.getLines.zipWithIndex) {
        val cols = line.split(",").map(_.trim)
        if (firstLine.size &lt;= 0 &amp;&amp; cols.length &gt; 0) {
          firstLine = cols.toList;
        } else {
          var doc: Document = Document("_id" -&gt; count)
          for ((a, b) &lt;- firstLine zip cols) {
            doc ++= Document(a -&gt; b)
          }
          docList = docList :+ doc
          collection.insertOne(doc)
        }
      }
  
      val doc3 = Document("name" -&gt; "MongoDB", "type" -&gt; "database",
        "count" -&gt; 1, "info" -&gt; Document("x" -&gt; 203, "y" -&gt; 102))
  
     collection.insertOne(doc)
     collection.find().subscribe((doc1: Document) =&gt; println(doc1.toJson()),
     (e: Throwable) =&gt; println(s"There was an error: $e"))
    }
  }
  </code></pre>