At the moment, I have a little JavaFX app that generates reports and statistics from the data on a remote MySQL-Server. I use EclipseLink for persistence. Since the access is read-only and the data doesn´t always need to be fresh, I thought I could speed things up by using an embedded DB (H2) that can be synchronized to the remote server when and if the user wishes to. The problem is, I don´t have a clue how to go about it.

目前,我有一个小型JavaFX应用程序,可以从远程MySQL服务器上的数据生成报告和统计信息。我使用EclipseLink进行持久化。由于访问是只读的并且数据并不总是需要新鲜的,我想我可以通过使用嵌入式数据库(H2)来加快速度,可以在用户希望的情况下同步到远程服务器。问题是,我不知道如何去做。

What I came up with so far, is to execute mysqldump, make a dump of the remote server and execute the resulting SQL script locally. This is surely far from elegant, so: Is there a patent solution for this task?

到目前为止我想出的是执行mysqldump,转储远程服务器并在本地执行生成的SQL脚本。这肯定远非优雅,所以:这项任务是否有专利解决方案?

1 个解决方案

#1


0

Well, 50 tables possible have a considerable amount of relations, this can be tricky... As far as I know there is nothing that automate this for you or something like that. Very possible that you will have to create your own logic to that. When I did something like what are you trying to do I used the logic of "last update", like, the local data have the timestamp of the time it was last synced with the remote, and the remote data have the timestamp of the last time the data was updated there (himself on the table, or even a relation to it like a One-To-One). Having that data, every time the local user enter a part of the system that can be outdated, the client connect to the server and check if the last update timestamp is bigger that the local synced timestamp, if so, it updates the full object and relation. I consumed some time to develop but at the end worked like a charm. There may be some other way to do it, but this was the way I found at the time. Hope it helps you with your problem.

好吧,50张表可能有很多关系,这可能很棘手......据我所知,没有什么可以为你或类似的东西自动化。很可能你必须为此创建自己的逻辑。当我做了类似你想要做的事情时,我使用了“上次更新”的逻辑,比如,本地数据的时间戳与上次与远程同步的时间有关,远程数据的时间戳是最后一次。数据在那里更新的时间(他自己在桌子上,甚至与一对一的关系)。拥有该数据,每当本地用户输入可能过时的系统部分时,客户端连接到服务器并检查上次更新时间戳是否大于本地同步时间戳,如果是,则更新完整对象和关系。我花了一些时间来开发,但最后工作就像一个魅力。可能还有其他一些方法,但这是我当时发现的方式。希望它可以帮助您解决问题。

更多相关文章

  1. (翻译)Java使用POI中的SXSSF处理大数据量Excel文档
  2. 黑马程序员——Java学习笔记 String类和基本数据类型对象包装类
  3. 在本地运行数据流导致JVM崩溃(OOM)
  4. 怎么在html,Javascript,vBscript中实现从网页上接收数据存入文本
  5. Java中累计时间的计算(以小时为最终结果)
  6. java 在数据库中添加新信息
  7. 数据截断:不正确的datetime值:“用于行1的列'date'
  8. 如何在JDBC数据源级别限制从Oracle返回的行数?
  9. 数据结构学习----线性表(Java版的实现)

随机推荐

  1. mac react-native从零开始android真机测
  2. Android使用Eclipse搭建NDK开发环境
  3. android-支持多种屏幕[屏幕支持概览] 五
  4. Android对返回键进行处理的方式
  5. 在Android的评论屏幕上实施网络呼叫的最
  6. 如何将值发送到Ionic中具有条件的其他页
  7. 将常量文本放在EditText中,这应该是不可编
  8. 使用mediaplayer + surfaceview来播放视
  9. android try catch并不影响性能
  10. Lance老师UI系列教程第三课->QQ登录注册