Dinesh Kumar P
Dinesh Kumar P

Reputation: 1168

H2 - Multiple applications access same H2 database

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

Upvotes: 4

Views: 6503

Answers (1)

Christian MICHON
Christian MICHON

Reputation: 2160

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

Upvotes: 14

Related Questions