• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alternative to properties file

 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want to use properties file, you can use XML configuration file.
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34396
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you planning on getting the datasource name without a property file? Hard coding it?
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That i can put it in spring object or might use properties file.. but it would be very minimum
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about the java.util.prefs package?
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a good option.. will def evaluate it and try to implement it.

Thanks..
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic