在网络共享上使用sqlite [英] Use of sqlite on network share

查看:374
本文介绍了在网络共享上使用sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


  1. 通过网络共享保留SQLite数据库文件是否在此模式下使用SQLite的唯一选项?



  2. $ b

    我没有看到很多并发更新操作。将有5-10个客户端尝试读取&更新同一个DB。在这种情况下,最好是使用一个entperise等级的DB(MySQL,Postgres)?

    解决方案

    引用


    SQLite使用读取器/写入器锁来控制对数据库的访问。
    (在Win95 / 98 / ME下,缺少对读写器锁的支持,而是使用
    概率模拟)但是请谨慎:如果数据库中的
    锁定机制可能无法正常工作文件是
    保存在NFS文件系统上。这是因为fcntl()文件锁定是
    在许多NFS实现上损坏。如果多个进程可能尝试同时访问
    文件,则应避免将SQLite
    数据库文件放在NFS上。在Windows上,Microsoft的文档说如果您没有运行
    Share.exe守护程序,
    锁定可能无法在FAT文件系统下工作。谁有很多经验的Windows
    的人告诉我,网络文件的文件锁定是非常buggy和不是
    可靠。如果他们说的是真的,在两个或多个Windows机器之间共享SQLite数据库
    可能会导致意想不到的问题。


    不会网络共享一个SQLite数据库文件,因为它看起来你会买自己讨厌的同步问题,导致很难再现数据损坏。



    换句话说,你使用一个文件共享机制来替代另一个DBMS的服务器能力。这些其他DBMS经过专门测试和现场硬化以实现多个客户端访问,尽管SQLite有很大的优点,但这不是其中之一。


    We are using SQLite (Xerial JDBC driver) on a windows desktop based Java application. Now we are moving on to a client-server version of the same application where multiple Java based Swing clients will be connecting to the same SQLite db file on the designated server Windows PC. Please correct me if I'm wrong:

    1. Is keeping the SQLite database file over network share the only option to use SQLite in this mode? or is there some other solution that I am missing ?
    2. Will using SQLite increase the chances of DB corruption ?

    I don't see lot of concurrent update operations. There will be 5-10 clients trying to read & update the same DB. In that case, is it better to use an entperise grade DB (MySQL, Postgres)?

    解决方案

    From the FAQ paragraph before the 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.

    I would not network share a SQLite database file as it appears you will be buying yourself nasty synchronization problems yielding hard to reproduce data corruption.

    Put another way, you are using a general file sharing mechanism to substitute for the server capabilities of another DBMS. These other DBMS are tested specifically and field-hardened for multiple client access, though SQLite has great merits, this isn't one of them.

    这篇关于在网络共享上使用sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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