4

I am using embedded database H2 in 2 web applications say WebApp1 and WebApp2. I run WebApp1 and execute some query to access H2 database. Mean while I run WebApp2, but it throws exception that H2 is currently been used by another process

My need is, I should be able to use H2 database by WebApp1 and WebApp2 at the same time. I analysed the below link but it tells about multiple connections but not about multiple applications.

http://www.h2database.com/html/features.html#multiple_connections
Dinesh Kumar P
  • 1,128
  • 2
  • 18
  • 32
  • 2
    Multiple applications making simultaneous multiple connections, same thing, you should be running H2 in server mode – MadProgrammer Aug 27 '14 at 07:10
  • 2
    You cannot share a database between applications while in embedded mode. Check the documentation for different ways of running the database. – sarah.ferguson Aug 27 '14 at 07:52

1 Answers1

14

You can use the embedded mode for WebApp1 and the server mode for WebApp2: in order to get this trick, both urls must be like "jdbc:h2:mydb;AUTO_SERVER=TRUE"

More info here: http://h2database.com/html/features.html#auto_mixed_mode

Christian MICHON
  • 2,140
  • 2
  • 19
  • 30