aspose file tools*
The moose likes JDBC and the fly likes Which solution is the cleanest way to obtain user and password??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Which solution is the cleanest way to obtain user and password???" Watch "Which solution is the cleanest way to obtain user and password???" New topic
Author

Which solution is the cleanest way to obtain user and password???

Travis Gibson
Ranch Hand

Joined: Oct 17, 2000
Posts: 100
Fellow ranchers,
I am trying to decide which way is cleaner(I.e. easier to maintain and less error prone) for obtaining User and Password values for create a database connections.
1.) Use ServletInitParameters(web.xml or default_app.webapp(I use Websphere) to store the User/Pass values....Thanks Mana Anna
2.) Use a db.properties file to store the User/Pass and use a Properties object to obtain User/Pass
Both have their drawbacks. I can only use the ServletInitParameters for Servlets(JSP). For Properties file I have the properties file in my classpath.
I am leaning towards the properties file approach. I'd appreciate any comments however.

------------------
Regards,
Travis M. Gibson, SCJP
Java Developer
www.travismgibson.com
travis@travismgibson.com


Regards,<BR>Travis M. Gibson, SCJP<BR>Java Developer<BR>www.travismgibson.com<BR>travis@travismgibson.com
Bhupinder Dhillon
Ranch Hand

Joined: Oct 12, 2000
Posts: 124
I would go with properties file simply b/c you can write comments in it so that it's self explanatory and you don't have to keep track of init parameters in the server configuration files.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You can also comment the deployment descriptors
The cleanest way of all is to use the database provider from the application server through JNDI (if the appserver supports this, of course).
Something like:

That way the servlet does not need to bother with database connections at all and will use connection pooling automatically if provided by the appserver.
[This message has been edited by Jeroen Wenting (edited April 23, 2001).]


42
 
 
subject: Which solution is the cleanest way to obtain user and password???