H2数据库多个连接 [英] H2 Database multiple connections
问题描述
我有以下问题: 两个不同系统上的应用程序的两个实例应共享一个小型数据库. 主要问题是两个系统只能通过网络文件夹交换数据. 我没有在某处设置数据库服务器的可能性.
I have the following issue: Two instances of an application on two different systems should share a small database. The main problem is that both systems can only exchange data through a network-folder. I don't have the possibilty to setup a database-server somewhere.
是否可以在网络文件夹中放置一个H2数据库,并使两个实例(同时)连接到该数据库?
Is it possible to place a H2 database on the network-folder and let both instances connect to the database (also concurrently)?
如果禁用文件锁定,可以使用嵌入式模式将这两个实例连接到数据库,对吗? 实例可以在数据库上执行READ或INSERT操作.使用多个并发的嵌入式连接是否会有数据损坏的风险?
I could connect with both instances to the db using the embedded mode if I disable the file-locking, right? The instances can perfom either READ or INSERT operations on the db. Do I risk data corruptions using multiple concurrent embedded connections?
推荐答案
也可以在不锁定文件的情况下打开数据库;在这个 是否由应用程序来保护数据库文件. 否则,将导致数据库损坏.
It is also possible to open the database without file locking; in this case it is up to the application to protect the database files. Failing to do so will result in a corrupted database.
我认为,如果您的应用程序始终使用相同的配置(网络文件夹上的共享文件数据库),则需要创建一个用于管理并发性的应用程序层
I think that if your application use always the same configuration (shared file database on network folder), you need to create an application layer that manages concurrency
这篇关于H2数据库多个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!