This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Alternative to properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Alternative to properties file" Watch "Alternative to properties file" New topic
Author

Alternative to properties file

saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
Hi,
I am creating one application in which i dont want to use normal properties file for storing the configuration.

I want to put all my configuration in database and provide an API for fetching the configuration..

Can any one give me some path forward. How should i design my database and API..

Thanks,
Saumil
Laxmikant Ruikar
Greenhorn

Joined: Nov 29, 2005
Posts: 23
Originally posted by saumil baxi:
Hi,
I am creating one application in which i dont want to use normal properties file for storing the configuration.

I want to put all my configuration in database and provide an API for fetching the configuration..

Can any one give me some path forward. How should i design my database and API..

Thanks,
Saumil


Welcome Saumil in Javaranch.


Property file contains key value pairs, the same way you can construct table such as cofing_property in which key and value(s) are columns. But if you would like to use properties as per user (or any other criteria) then you have to add one more column.

Regarding API, I will suggest you to have Helper class which is populate Hashtable or your favorite collection as per table values. And in Helper class you will have getter method to fetch value from collection.

LDR
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Hi Saumil,

I guess it won't be a good idea by storing the configuration in database because to fetch this configuration, you some how need to connect to database initially. For that if you donot want to use your properties file, I guess you need to hardcore the code, which is not a good practice.

Most of the times, lesser hits to the database is recommended for optimum performance.

Are you planning to create your own API classes for the database connection?

Regards,
Kiran.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

If you don't want to use properties file, you can use XML configuration file.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
Thanks for the response..

My final objective is not to use any properties or XML file..

Laxmikant has given me the approach that i need to follow..
I agree that using database is a very expensive thing but we can use caching method to reduce time. [ ]..
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

How are you planning on getting the datasource name without a property file? Hard coding it?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
That i can put it in spring object or might use properties file.. but it would be very minimum
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
What about the java.util.prefs package?
saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
Looks like a good option.. will def evaluate it and try to implement it.

Thanks..
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
I agree that using database is a very expensive thing but we can use caching method to reduce time. [ ]..

On the contrary, using a database to obtain trivial amounts of data should be highly efficient.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
jQuery in Action, 2nd edition
 
subject: Alternative to properties file
 
Similar Threads
JDK Logging question
properties file
Log4J
Configuration for web application
Question about properties file