title: MongoDB with Scala language
body: <p>i am new to MongoDB and Scala language</p>
  <p>i am using scala language to connect mongodb locally</p>
  <p>i am using below dependency</p>
  <blockquote>
  <p>//
  <a href="https://mvnrepository.com/artifact/org.mongodb.scala/mongo-scala-driver" rel="nofollow noreferrer">https://mvnrepository.com/artifact/org.mongodb.scala/mongo-scala-driver</a></p>
  <p>libraryDependencies += &quot;org.mongodb.scala&quot; %% &quot;mongo-scala-driver&quot; %
  &quot;4.2.3&quot;</p>
  </blockquote>
  <p>what I tried</p>
  <pre><code>object Demo extends App {
    
    val mongoClient: MongoClient = MongoClient(&quot;mongodb://127.0.0.1:27017/&quot;)
    val database: MongoDatabase = mongoClient.getDatabase(&quot;DemoDB&quot;)
    println(database)
  
    val collection: MongoCollection[Document] =database.getCollection(&quot;demodata&quot;);
    val observable = collection.find();
  }
  </code></pre>
  <p>the above code returning the data in below format</p>
  <pre><code>FindObservable(com.mongodb.reactivestreams.client.internal.FindPublisherImpl@6253c26)
  </code></pre>
  <p>I also tried with</p>
  <pre><code>observable.subscribe ( new Observer[Document] {
    override def onNext(result: Document): Unit = println(result.toJson())
    override def onError(e: Throwable): Unit = println(&quot;Failed&quot; + e.getMessage)
    override def onComplete(): Unit = println(&quot;Completed&quot;)
  })
  </code></pre>
  <p>i also tried <code>printResult()</code> and <code>printHeadResult()</code> method also but none of the way is working</p>
  <p>please help
  thanks in advance</p>