帮助提供快速但肮脏的数据库同步解决方案
我对截止日期有疑问。截止日期是明天:S 幸运的是,这不一定是最好的解决方案;甚至不是一个好人。我只需要一个部分工作,我将很快对此进行描述。我想让你知道的是,我正在寻找最快和最肮脏的解决方案,所以我的想法可能听起来很糟糕。
因此,在过去的几天里 我一直在尝试同步位于在 Windows Mobile 设备中,MySQL 数据库位于中央 Linux 服务器上。 Microsoft 的演练 包含一个我不知道如何处理的网络服务(我在这方面的知识非常有限)。据我了解,有一个服务应该位于服务器端,但由于各种原因这是不可能的(包括它是一台linux机器)。此外,我还没有弄清楚如何制作 mysql 同步提供程序。
我的解决方案(请注意,这是一个丑陋的解决方案)是在服务器上创建一个 Java Web 服务,负责跟踪每个 Windows Mobile 的同步请求并做出适当的响应。我的想法是这样的:
每个 Windows Mobile 设备都将包含一个本地数据库 (SQL Compact)。当存在活动的互联网连接时,它将向网络服务发送请求以同步其数据库并发送用户名和密码。 Web 服务将从这些凭据中查找最后的同步请求(这是请求时数据库的转储),并将其与当前数据库状态进行比较。该服务只会发送更改作为响应。发送响应后,它将存储当前数据库状态作为用户下一个同步请求的最后一个同步请求。 Windows Mobile 设备所要做的就是遵循响应(简单的 CRUD 语句)。
所以,我的问题最后是:如何存储数据库状态以便稍后将其与未来状态进行比较?
当然,不用说,如果有更好的解决方案可以快点完成后,我就可以放弃这整个想法了。
对于这种情况,您需要了解以下信息:服务器运行的是 Linux。它的数据库是MySQL,我无法修改架构。不过,我可以在服务器上安装软件,例如网络服务。最后,Windows Mobile 设备当前正在运行 SQL Compact。当然,这不应该花费任何成本,因为它不会是最终的解决方案(一旦我弄清楚一些事情,它将使用 Microsoft Sync Framework)。
非常非常感谢。我还想让你知道,这不是一个“给我代码”的问题,我主要是在寻找任何类型的反馈(评论/想法/建议/咆哮/等等)。
I have a problem with a deadline. And that deadline is tomorrow :S Luckily it doesn't have to be the best solution; not even a good one. I only need one part working which I will describe shortly. What I want you to know is that I looking for the quickest and dirtiest solution right so my idea maybe sound really bad.
So, for the past couple of days I've been trying to synchronize a database located in a Windows Mobile device with a MySQL database located to a central linux server. Microsoft's walkthrough contains a web service which I am not sure how to handle (I have very limited knowledge in this area). As far as I understand, there is a service which should be located in the server side, but this is not possible for various reasons (including the fact that it is a linux machine). Furthermore, I have yet to figure out how to make a mysql sync provider.
My solution, and this is an ugly one mind you, is to create a Java web service on the server that is responsible for tracking each Windows Mobiles' sync requests and respond appropriately. Here is how I think it will go:
Each Windows Mobile device will contain a local database (SQL Compact). When there is an active internet connection, it will send a request to the web service to sync their database sending along their username and password. The web service will look for the last sync request from these credentials (which is a dump of the database at the time of the request) and compare it with the current database state. The service will only send the changes as a response. Once the response is sent, it will store the current database state as the user's last sync request for the next one. All the Windows Mobile device has to do is follow the response (simple CRUD statements).
So, my question, finally, is: How can I store the database state in order to later compare it with a future state?
Of course, needless to say, if there is a better solution that can be done quickly, I can discard this whole idea.
For this case, here is what you need to know: the server is running linux. The database on it is MySQL and I cannot modify the schema. I can however install software on the server, like a webservice. Finally, the Windows Mobile devices are currently running SQL Compact. And of course, this should not cost anything since it will not be the final solution (which will use the Microsoft Sync Framework once I get to figure out some things).
Thank you very very much. I'd also like you to know that this is not a "give me code" question, I am mainly looking for any type of feedback (comments/ideas/suggestions/rants/etc).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一种随机的(可能是愚蠢且行不通的)方法来解决这个问题。如果我理解正确的话,您只在一个方向上同步(从 MySQL 数据库到移动设备)。如果是双向同步,那么这根本不起作用。
在数据库上设置复制以复制到数据的从属副本。在该从数据库中,在涉及的表上放置触发器,并且对于每次修改(删除、更新、插入),写入必要的信息以将 CRUD 语句生成到某个文件/表。然后在同步期间,只需将这些语句重播到设备,然后删除/清除文件。然后,下一次同步将重播累积的下一组语句。
Here is a random (and possibly stupid and unworkable) way to address it. If I understand correctly, you are synchronizing in only one direction (from the MySQL database to the mobile device). If it is two-way sync, then this will not work at all.
Set up replication on the database to replicate to a slave copy of the data. In that slave database, put triggers on the tables involved and for each modification (delete, update, insert), write the necessary information to generate your CRUD statements to some file/table. Then during the sync, just replay those statements to the device and then delete/clear the file. The next sync would then replay the next set of statements that were accumulated.
为什么不简单地为数据库中的所有数据创建一个 MD5 密钥并存储它呢?这不会让您看到发生了什么变化,但至少您会知道已经进行了更改。
Why not simply create an MD5 key for all the data in the database and store that? This will not let you see what changes took place but at least you will know that a change has been made.