H2-多个应用程序访问同一个H2数据库 [英] H2 - Multiple applications access same H2 database

查看:372
本文介绍了H2-多个应用程序访问同一个H2数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在2个Web应用程序(例如 WebApp1 WebApp2 )中使用嵌入式数据库 H2 .我运行WebApp1并执行一些查询以访问H2数据库.这意味着在我运行WebApp2时,但是它抛出 H2当前被另一个进程使用

的异常

我需要的是,我应该能够同时使用WebApp1和WebApp2的H2数据库.我分析了以下链接,但它讲述了多个连接,但没有涉及多个应用程序.

http://www.h2database.com/html/features.html#multiple_connections

解决方案

您可以将嵌入式模式用于WebApp1,将服务器模式用于WebApp2:为了获得此技巧,两个URL都必须类似于"jdbc:h2:mydb" ; AUTO_SERVER = TRUE"

此处的更多信息: http://h2database.com/html/features.html#auto_mixed_mode

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

解决方案

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

这篇关于H2-多个应用程序访问同一个H2数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆