2

What I got from the documentation is, It runs as a separate process on other machine and I can communicate with it using the mongo db client driver for java and I can do normal operations.

But I doubt If I can use MongoDB as an embedded db in my java application? I mean, not as a separate process on other machine or not as a separate process on the same machine. It should be part of java application.

Can you please help me out?

Manohar
  • 653
  • 1
  • 10
  • 15
  • 4
    possible duplicate of [Can mongodb be used as an embedded database?](http://stackoverflow.com/questions/6115637/can-mongodb-be-used-as-an-embedded-database) – zero323 Oct 24 '13 at 12:28

1 Answers1

8

No, that's not possible. MongoDB is a native C++ application that uses memory-mapped files, opens sockets, etc. It won't run in a JVM.

Also, MongoDB was made for web scale applications, big data, failover clusters (replica sets) and auto-sharding, none of which really make sense in an embedded application. Also, it's quite aggressive in terms of memory usage which is undesirable for embedded applications.

--EDIT after zero323's comment--

You might want to take a look at db4o an object database for java that was made for embedding.

Also, when embedding databases, the licenses can bite you and force you to release your code under the same license, in case of MongoDB the AGPL.

mnemosyn
  • 45,391
  • 6
  • 76
  • 82
  • ...and having your whole code infected with the AGPL can be really cumbersome, because it requires you to license it to everyone who uses it over a network. With a normal GPL application it's OK to keep the source when it only runs on your own servers. – Philipp Oct 24 '13 at 14:50