数据库处理有2个进程 [英] Database handling with 2 processes
问题描述
我有一个,有2份申请。
I have a an application that has 2 parts.
- 在创造内容的服务。
- 使用内容的应用程序
每个这些运行作为不同的过程。的问题是,无论是他们共同的数据库。而且我经常获取数据库锁定错误,既当服务尝试写的东西和用户界面读取数据。此外,反之亦然。 怎么去呢?
Each of these run as different processes. The problem is that both of them share a database. And I frequently get database locked error, both when the service tries to write something and the UI is reading data. Also vice versa. How do go about this?
- 用于访问数据库的类是一个单例类。但由于这两种UI和放大器;该服务是两个不同的过程,有2单身我presume。所以这并不能帮助。
- 甚至
同步
不会帮我猜想,因为又因为2个不同的过程。 -
内容提供商
也许一个选项,但因为我使用复杂的查询去挖掘信息,这将是真的很难使用太多。
- The class used to access DB is a singleton class. But since both UI & the service are 2 different processes, there are 2 singletons I presume. So that doesn't help.
- Even
synchronise
won't help I suppose, since again because of 2 different processes. Content Providers
maybe an option, but since I use complex queries to dig info, it would be really hard to use that too.
我如何获得这两个进程共享的数据库。 任何线索将大大AP preciated。
How do I get the two processes share the database. Any cues would be greatly appreciated.
推荐答案
使用内容提供商是一种选择。另一种方法是看一看 Berkeley DB的。该BDB SQL API 是SQLite的兼容和BDB锁管理器允许多个线程和/或进程读取/写入到数据库的并发。
Using a content provider is one option. Another is to take a look at Berkeley DB. The BDB SQL API is SQLite compatible and the BDB lock manager allows multiple threads and/or processes to read/write to the database concurrently.
这篇关于数据库处理有2个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!