This repository contains code samples for the Quick Start blog post series.
You can read more about the Quick Start series on the MongoDB Developer Hub.
- MongoDB & Java - CRUD Operations Tutorial
- Java - Mapping POJOs
- Java - Aggregation Pipeline
- Java - Change Streams
- Java - Client Side Field Level Encryption
- Java - Multi-Doc ACID Transactions
To get started with MongoDB Atlas and get a free cluster read this blog post.
- Java 21
- Maven 3.8.7.
- Compile:
mvn clean compile
- Run the
HelloMongoDB
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.HelloMongoDB"
- Run the
Connection
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.Connection" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
Create
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.Create" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
Read
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.Read" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
Update
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.Update" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
Delete
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.Delete" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
MappingPOJO
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.MappingPOJO" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
AggregationFramework
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.AggregationFramework" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
ChangeStreams
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.ChangeStreams" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
ClientSideFieldLevelEncryption
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.csfle.ClientSideFieldLevelEncryption" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
Always start the ChangeStreams
class in the transactions
package first because it creates the product
collection with the required JSON Schema. See the related blog post.
- Run the
ChangeStreams
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.transactions.ChangeStreams" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
- Run the
Transactions
class:
mvn compile exec:java -Dexec.mainClass="com.mongodb.quickstart.transactions.Transactions" -Dmongodb.uri="mongodb+srv:https://USERNAME:[email protected]/test?w=majority"
Maxime Beugnet
- [email protected]
- MaBeuLux88 on GitHub
- MaBeuLux88 in the MongoDB Developer Community forum.