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.
2.7k (mongo-java-driver)
GitHub · Sept 2026
5.13.0 (September 2026)
GitHub · Sept 2026
Java Sync driver v5.x
MongoDB Docs · Sept 2026
Guide
Web Development
MongoDB
A weekend for the core, then reference
Intermediate
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,IndexesandAggregatesfor 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
- Connecting: create one
MongoClientfor the application and share it. - CRUD with the
FiltersandUpdatesbuilders, which catch many mistakes at compile time. - The POJO and codec pages, so your domain classes map cleanly to documents.
- Aggregation with the
Aggregatesbuilder, translating pipelines you tested in mongosh. - 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.
Ready to start?
Opens on MongoDB in a new tab.
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.
Follow along
New writing, resources and project ideas land here first.