gpt4 book ai didi

java - 在网络共享上使用 sqlite

转载 作者:行者123 更新时间:2023-11-30 04:59:57 25 4
gpt4 key购买 nike

我们在基于 Windows 桌面的 Java 应用程序上使用 SQLite(Xerial JDBC 驱动程序)。现在,我们将转向同一应用程序的客户端-服务器版本,其中多个基于 Java 的 Swing 客户端将连接到指定服务器 Windows PC 上的同一 SQLite 数据库文件。如果我错了,请纠正我:

  1. 通过网络共享保留 SQLite 数据库文件是在此模式下使用 SQLite 的唯一选择吗?或者我还缺少其他一些解决方案吗?
  2. 使用 SQLite 会增加数据库损坏的机会吗?

我没有看到很多并发更新操作。将有 5-10 个客户端尝试读取和更新同一个数据库。在这种情况下,使用企业级数据库(MySQL、Postgres)是否更好?

最佳答案

摘自 one quoted 之前的常见问题解答段落:

SQLite uses reader/writer locks to control access to the database. (Under Win95/98/ME which lacks support for reader/writer locks, a probabilistic simulation is used instead.) But use caution: this locking mechanism might not work correctly if the database file is kept on an NFS filesystem. This is because fcntl() file locking is broken on many NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time. On Windows, Microsoft's documentation says that locking may not work under FAT filesystems if you are not running the Share.exe daemon. People who have a lot of experience with Windows tell me that file locking of network files is very buggy and is not dependable. If what they say is true, sharing an SQLite database between two or more Windows machines might cause unexpected problems.

我不会通过网络共享 SQLite 数据库文件,因为看起来您会给自己带来令人讨厌的同步问题,从而导致难以重现数据损坏。

换句话说,您正在使用通用文件共享机制来替代另一个 DBMS 的服务器功能。这些其他 DBMS 经过专门测试并针对多个客户端访问进行了现场强化,尽管 SQLite 有很大的优点,但这不是其中之一。

关于java - 在网络共享上使用 sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7137994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com