简体   繁体   English

将多个桌面应用程序连接到一个在线数

[英]Connect multiple desktop apps to one online database

I'm starting a new project. 我正在开始一个新项目。 It consists of: 它包括:

  • Java desktop application downloadable from the internet with a client database. 可从Internet上下载带有客户端数据库的Java桌面应用程序。
  • PHP website on the internet with a server database. 互联网上的PHP网站与服务器数据库。

The user who downloaded the app will use it to add items (not important what are they now) to the local database offline. 下载应用程序的用户将使用它将项目(现在不重要的是)离线添加到本地数据库。 When/If he is online, the item will be added to the server database so other connected users (through the desktop app or through the website) will see it. 当/如果他在线时,该项目将被添加到服务器数据库,以便其他连接的用户(通过桌面应用程序或通过网站)将看到它。 I googled the issue and found it's more complected than I guess. 我用谷歌搜索了这个问题,发现它比我想象的要复杂得多。 One of the solution is to use some ready tools like SymmetricDS and Daffodil to gain in term of security , performance and scalability , but they're difficult to configure and install in both client and server side, and need the access to command prompt which requires me to pass to a dedicated host (well, that is not a real problem). 其中一个解决方案是使用一些现成的工具,如SymmetricDSDaffodil来获得安全性性能可伸缩性 ,但它们很难在客户端和服务器端配置和安装,并且需要访问命令提示符,这需要我传递给一个专门的主人(好吧,这不是一个真正的问题)。 Also, all what I want is just what I've described, not all what these tools actually provide. 此外,我想要的只是我所描述的,而不是这些工具实际提供的所有内容。

  • Can I achieve that by myself within my Java application and maybe with the help of the web server PHP? 我可以在Java应用程序中自己实现这一点,也可以在Web服务器PHP的帮助下实现吗?

I'm using MySQL for the info. 我正在使用MySQL获取信息。

Edit: what really matters is to send items to the server database. 编辑:真正重要的是将项目发送到服务器数据库。 Reading it can be less tricky using RSS Feed reading, for example. 例如,使用RSS Feed读取读取它可能不那么棘手。

Basically, you can use HTTP/HTTPS API. 基本上,您可以使用HTTP / HTTPS API。 When a user online, send items to your php file and mark the items "sended" at local database. 当用户在线时,将项目发送到您的php文件并在本地数据库中标记“已发送”项。 But you have to control edited or deleted statuses. 但您必须控制已编辑或已删除的状态。 So, yes that is much complicated but a solution. 所以,是的,这很复杂,但却是一个解决方案。

Well the easiest solution that comes to my mind would be to save for each item a last edit date (on the server as well as on the client). 那么我想到的最简单的解决方案是为每个项目保存最后一个编辑日期(在服务器上和客户端上)。 Additionaly you have to keep track when a client got his last update from the server. 另外,当客户端从服务器获得最后一次更新时,您必须跟踪。

So whenever a client goes online the server sends him all updates. 因此,每当客户端上线时,服务器都会向他发送所有更新。

But for that you have to make sure that the time on the client and the server are the same, and it doesn't solve the problem what happens if two clients edit the same item. 但是为此你必须确保客户端和服务器上的时间是相同的,并且它不能解决问题,如果两个客户端编辑同一个项目会发生什么。

CouchDB solves the distributed synchronization problem very nicely, but it is a NoSQL DB. CouchDB很好地解决了分布式同步问题,但它是一个NoSQL DB。 Depending on what your application should do, using it would boil down to using instances of CouchDB both locally inside very application, and on the central server. 根据您的应用程序应该做什么,使用它可以归结为在本地内部非常应用程序和中央服务器上使用CouchDB实例。

You'd have to deal with conflicts nevertheless. 不过,你必须处理冲突。 The only thing CouchDB will support you with is easier detection of conflicts, and the data of both conflicting edits, so your application can work it out either automatically, or with user help. CouchDB唯一支持您的是更容易检测冲突和两个冲突编辑的数据,因此您的应用程序可以自动或在用户帮助下解决。

On the other hand, generatin a unique id on the central server can be as easy as adding the creating user's id to each item id. 另一方面,在中央服务器上生成唯一ID可以像将创建用户的id添加到每个项ID一样简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM