Skip to content
Sebastian Schlicht edited this page Sep 9, 2013 · 8 revisions

Installation

Firstly import the GPG key of MongoDB by calling
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

then add the MongoDB repository to apt via

sudo apt-get update```

and install the latest version per  
`sudo apt-get install mongodb-10gen`

as described [at the MongoDB download guide](http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/).
Now you have to add the dependecy for the Java driver for MongoDB.  

    <dependency>
    	<groupId>org.mongodb</groupId>
    	<artifactId>mongo-java-driver</artifactId>
        <version>2.11.2</version>
    </dependency>

## Working with MongoDB
a short tutorial for an easy start:  
http://www.mkyong.com/mongodb/java-mongodb-hello-world-example/

### Not documented
The [cursor.next()](http://docs.mongodb.org/manual/reference/method/cursor.next/) method throws a `NoSuchElementException` if the cursor does not has a next element just like an iterator does.
Clone this wiki locally