MongoDB: Java

Accessing MongoDB via Java

These instructions assume that you have already created a MongoDB instance somewhere.

You might have followed these three steps, for example:

If you did so, you’ll be able to look up the MongoDB URI, something such as:

mongodb://<dbuser>:<dbpassword>@ds050559.mlab.com:50559/corgis

The pieces of this are as follows:

hostname port database name
ds050559.mlab.com 50559 corgis

The dbuser and dbpassword are whatever you set them to when you created the database user (they are NOT your mlab.com username and password.)

With this, you are ready to start coding.

MongoDB Java Driver v3.3 References

Other references