Hi Folks, I have a JAR application, that automatically runs by a system scheduler created by me. Now, this JAR application creates a connection to a Oracle DB everytime it runs. or creating the connection,I have hardcoded the JDBC-URL string, schema-name, and password inside the main class. Instead of hardcoding, can't I just set some System environment variables, and read it from Java? If it's possible, let me know how!!!
Give me example for UNIX, as well as Windows system.
Normally I add a property file to my build and load it relative to the path used by the classloader for Main i.e. you can load it from within the jar when you deploy or from a directory when in dev (same code loads either).
You can do system properties instead but this seems neater, i.e. its all contained in the jar certainly a step up from had coding withing the class, if you don't want to do that you could just add them as command line arguments for instance.
Some stuff on it here, its done a lot so should be all over the web ..