I am looking for a library which allows to run an in-process database like SQLJet, but it has to be accessible from multiple vms (on the same machine) simultaneously like an independent database server. At best something like this: You create a new file-system database, then open a connection to it from one vm. If you then try to do the same thing from a different vm, it checks if theres already a connection to it and syncs with it. If there's no such thing, any ideas how i can run a in-process database server in java? Doesnt have to be sql, mongoDB or any database system will do. The important part is, that i do not have to run a seperate database engine, but it has to be accessible from multiple vms.
Asked
Active
Viewed 656 times
1
-
Did you try Apache Derby aka Java DB? Which allows both Embedded as well as Remote Mode. – shazin Jun 24 '14 at 08:48
-
1or maybe h2? http://www.h2database.com/html/features.html take a look at the mixed mode – Moh-Aw Jun 24 '14 at 09:00
-
Isn't "in-process" and "accessible from multiple VMs" a contradiction? – Henry Jun 24 '14 at 09:02
1 Answers
2
Use the H2 in TCP server mode. In one of your VMs start it like so:
Server server = Server.createTcpServer(args).start();
Other VM can connect using JDBC:
JDBC driver class: org.h2.Driver
Database URL: jdbc:h2:tcp://localhost/~/test

Stefan
- 12,108
- 5
- 47
- 66