如何使用嵌入式JavaDB数据库部署Java Swing应用程序? [英] How to deploy a Java Swing application with an embedded JavaDB database?

查看:202
本文介绍了如何使用嵌入式JavaDB数据库部署Java Swing应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了使用嵌入式JavaDB数据库的Java Swing应用程序。数据库需要存储在某个地方,并且需要在第一次运行时创建数据库表。执行这些过程的首选方法是什么?



我应该始终在本地目录中创建数据库,然后首先检查数据库文件是否存在,存在让用户创建表(或至少显示一个消息,表将被创建)。



或者我应该让用户选择一个路径?但是我必须将路径保存在某处。应该使用 Preferences.systemRoot(); ,并检查该变量是否在启动时设置?



如果用户选择路径并将其保存在首选项中,是否可以获得用户权限的任何问题?或者应该在用户存储数据库的地方安全吗?或者我该如何处理?



此过程的任何其他建议?

解决方案

我会让用户选择。这样他们可以运行多个实例(同时或其他)。提供合理的默认值将是一个很好的举动。



使用首选项API存储路径(我将存储每个用户,但可能会有所不同取决于您的应用程序),并使用文件对象来确定目录是否存在和/或被正确地被许可。


I have implemented an Java Swing application that uses an embedded JavaDB database. The database need to be stored somewhere and the database tables need to be created at the first run. What is the preferred way to do these procedures?

Should I always create the database in the local directory, and first check if the database file exist, and if it doesn't exist let the user create the tables (or at least show a message that the tables will be created).

Or should I let the user choose a path? but then I have to save the path somewhere. Should I save the path with Preferences.systemRoot();, and check if that variable is set on startup?

If the user choses a path and save it in the Preferences, can I get any problems with user permissions? or should it be safe wherever the user store the database? Or how do I handle this?

Any other suggestions for this procedure?

解决方案

I would let the user choose. That way they can run multiple instances (simultaneously or otherwise). Supplying a sensible default would be a good move.

Store the path using the Preferences API (I would store per-user but that may differ depending on your application), and use the File object to determine if directories exist and/or are permissioned properly.

这篇关于如何使用嵌入式JavaDB数据库部署Java Swing应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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