This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
After many months away I am starting to get back to my Java project, which means I am relearning may things I thought I understood... I have a program that performs a JDBC connection but I don't want to hardcode the IP address or Database drivers, I would like to be able to store several and simply 'activate' the one I'm currently using. If I remember right, I can put these parameters in something called a Properties file and access them at run time. This way, I only need top change the properties file in order to change databases, machines, etc. So what are these things, how do I set one up, and how do I access one from a program? Thanks, Joel
Wait a minute, I'm trying to think of something clever to say...<p>Joel
I think what you are looking for is a ResourceBundle. Sun has a tutorial on how to used resource bundles to create text properties files. I hope this is helpful. [This message has been edited by Don Gardner (edited October 25, 2001).]
Joined: Mar 23, 2001
Thanks for the links. It seems, though, that ResourceBundle is primarily concerned with Locales and language translation. They mention Properties files, which as I thought are simple text files, so I think this close to what I want. All I need to know now is how to access those files on the fly to retrieve Strings. Joel
Yes, that looks MUCH more like what I had in mind! I just started learning some of the IO stuff yesterday (including how to create a new .jpg) and this goes hand in hand with what I was reading. So can I have multiple properties in this file or would I need multiple files for different values, like on e file for IP address, one file for JDBC Driver name, etc.? Also, I'm assuming that "/files/..." would have to be a sub-folder underneath the folder the program is running in (when creating the .jpg it automatically goes in the same folder as the program). What are the rules for specifying a target location? Thanks for the help, it is most appreciated! Joel