Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Guide · Web DevelopmentFree

MongoDB Java Driver Documentation

The official guide to the MongoDB Java Sync driver: connecting, CRUD, builders for type-safe filters and updates, aggregation, POJO mapping with codecs, indexes, transactions and monitoring. Read it even if you use Spring, because Spring Data MongoDB runs on this driver and its errors surface from here.

GitHub stars

2.7k (mongo-java-driver)

GitHub · Sept 2026

Latest release

5.13.0 (September 2026)

GitHub · Sept 2026

Docs cover

Java Sync driver v5.x

MongoDB Docs · Sept 2026

Format

Guide

Topic

Web Development

Provider

MongoDB

Time needed

A weekend for the core, then reference

Level

Intermediate

Access

Free

What these docs cover

These are MongoDB's docs for the Java Sync driver, the standard blocking driver for Java applications, covering the current 5.x line. The sections are:

  • Get Started and Connect: MongoClient, connection strings, connection pools and TLS.
  • Databases and collections, and CRUD operations.
  • Builders: helper classes such as Filters, Updates, Projections, Sorts, Indexes and Aggregates for writing queries in Java rather than raw documents.
  • Aggregation.
  • Data formats: Document, BSON types, and mapping your own classes (POJOs and records) with codecs.
  • Indexes, running commands, search and vector search.
  • Logging, monitoring and security.
  • Reference: compatibility tables, upgrade notes and the API docs.

For non-blocking code there is a separate Reactive Streams driver, which MongoDB recommends when "your Java application requires asynchronous stream processing". Kotlin has its own driver docs as well.

Why read it if you use Spring?

Spring Data MongoDB is built on this driver. Connection pool settings, timeouts, write concern, duplicate key errors, codec problems and transaction behaviour all come from the driver, and the Spring docs assume you know it. Half an hour with the builders and POJO pages also makes Spring's Criteria and mapping annotations much easier to reason about.

What to read first

  1. Connecting: create one MongoClient for the application and share it.
  2. CRUD with the Filters and Updates builders, which catch many mistakes at compile time.
  3. The POJO and codec pages, so your domain classes map cleanly to documents.
  4. Aggregation with the Aggregates builder, translating pipelines you tested in mongosh.
  5. Transactions, once you have a real multi-document invariant to protect.

Prerequisites

Solid Java, a build tool such as Maven or Gradle, and basic MongoDB queries in mongosh. Check the compatibility page for the Java and server versions your driver release supports before upgrading.

Common questions

Sync or Reactive Streams? Sync for most applications and for learning. Reactive only if the rest of your stack is reactive, such as Spring WebFlux.

Is it free? Yes, the driver is open source under Apache 2.0.

What can I do after it? Build Java services on MongoDB with typed queries, mapped classes, aggregation and correctly configured connections, and debug problems that surface through Spring.

Best for: Java developers using MongoDB directly or through Spring who want to understand the layer everything else runs on.

databasebackendjavaopen source

Ready to start?

Opens on MongoDB in a new tab.

Open resource
Link broken or out of date?

Report a problem

With "MongoDB Java Driver Documentation". Only Tauseef reads this.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.