简体   繁体   English

具有本地和在线数据库的桌面应用

[英]Desktop app with local and online database

I want to create a Desktop App(Software), preferably in Java, which connects to a central MySQL DB on a local network whenever available. 我想创建一个桌面应用程序(软件),最好使用Java创建,该应用程序在可用时会连接到本地网络上的中央MySQL DB。

I also want it to store and use a copy of the same DB when the central DB is not available, and sync whenever the central DB is available. 我还希望它在中央数据库不可用时存储和使用同一数据库的副本,并在中央数据库可用时进行同步。

How can I store data locally, I mean which kind of database should I use for local database? 如何在本地存储数据,我的意思是应该为本地数据库使用哪种数据库?

Also, are there any tools which speed up the Desktop App development? 另外,是否有任何工具可以加快Desktop App的开发速度?

Let's suppose that you will implement your solution in Java. 假设您将用Java实现解决方案。 You will need some classes (ie Data Access Obejcts, DAOs) in charge of interacting with the database on the network and on a file based database embedded in the application (the "local" database). 您将需要一些类(例如,数据访问对象,DAO)负责与网络上的数据库以及应用程序中嵌入的基于文件的数据库(“本地”数据库)进行交互。

What you need: 您需要什么:

  1. A local database that you can ship with your application like H2 www.h2database.com, HSQLDB http://hsqldb.org/ or Derby db.apache.org/derby/. 您可以随应用程序一起提供的本地数据库,例如H2 www.h2database.com,HSQLDB http://hsqldb.org/或Derby db.apache.org/derby/。
  2. To develop your DAOs (using JDBC or Hibernate) in such a way that you can instantiate them with different drivers, URLs, login/pwd and use only SQL standard / functions supported both by MySql and by the local DBMS. 以某种方式开发DAO(使用JDBC或Hibernate),以便可以使用不同的驱动程序,URL,登录名/密码来实例化它们,并仅使用MySql和本地DBMS都支持的SQL标准/函数。 In practice you must avoid using DB specific functions. 实际上,您必须避免使用特定于数据库的功能。

例如,您可以使用Hibernate或JPA,它们与您的应用程序集成得很好并且很容易。

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

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