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?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
The standard way is to have a properties (either java.util.Properties or XML) file in which is stored the database details. This can be writeable by the user of course, and passwords stored in such a file need to be encrypted.
It's a nice idea to give the user a means of setting these from the application rather than having to edit the file manually though.
In addition to the answers already given I would suggest externalizing the reference to the properties file by specifying it as a command-line option, e.g:
You can then grab the path like so:
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: