File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Correct place to store the DB credentials Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Correct place to store the DB credentials" Watch "Correct place to store the DB credentials" New topic
Author

Correct place to store the DB credentials

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8435

I got one servlet based application, which connects to a DB among other things.
Right now I am hardcoding the DB credentials.

We will soon be shifting to Beta phase, where the application will be test deployed at multiple client sites. Obviously the DB credentials need to be changed for every site.
I was wondering if the web.xml is the correct place to put these credentials? This would certainly avoid me the hassle of rebuilding it every time, but I am not really comfortable with the credentials lying out in a human readable format.
I am being paranoid over this, considering that the web.xml is not accessible to the public?


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56185
    
  13

As we're using Hibernate, the credentials never appear at he UI layer, but in other situations I've tended to put then in external properties files.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8435

Hibernate is not applicable in my scenario.

Any particular reason for the properties file instead of the web.xml? Are there any problems if they are in the web.xml?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
I'd second putting stuff into properties files instead of web.xml. DB configuration has nothing to do with web setup (which is what web.xml is about).

These days, the only parameter I keep in web.xml is the name of the properties file that has all the configuration data.


Android appsImageJ pluginsJava web charts
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8435

Ok.
Thanks Bear, Ulf for the input.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Correct place to store the DB credentials
 
Similar Threads
Identifying a new physical connection versus a logical connection in a jdbc connection pool
Login page security using Servlet
issue with duke bank application
EJB, JDBC Realm, Session tracking
Glasfish: JDBC Realm and Session Tracking.