哪种是在桌面应用程序上外部化数据库配置的最佳方法? [英] which is the best way to externalize a database configuration on a desktop app?

查看:48
本文介绍了哪种是在桌面应用程序上外部化数据库配置的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用桌面应用程序,并且我们将Eclipse RCP与EclipseLink一起使用。

我所有的数据库配置都在一个类中,但是我需要这些(数据库URL,密码,用户名)是可配置的。

哪种方法最好?

I'm working in a desktop app, and we're using Eclipse RCP with EclipseLink.
All my database configuration is inside a class, but I'll need these thing (database URL, password, username) configurable.
Which is the best way to do that?

推荐答案

最简单的方法是使用一些简单的属性文件和java.util.Properties来读取它。

Easiest way would be to use some simple property file and java.util.Properties to read it.

您可以从类路径中读取文件,例如:

You can read the file from classpath, e.g:

Class.getResourceAsStream ("resource.properties");

这篇关于哪种是在桌面应用程序上外部化数据库配置的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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