• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Obtaining User/Password info for DB connections

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Fellow ranchers,
I have a question for you all. I am would like to create a connection to a database without having to hardcode the user/pass in the connection code or having to read a properties files to obtain it.
Any there any other ways that I could do this so that the code is clean, the user/pass can be changed without impacting connection code and without having to keep track of a properties file?

------------------
Regards,
Travis M. Gibson, SCJP
Java Developer
www.travismgibson.com
travis@travismgibson.com
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using servlets, you can have the user and password as part of the initial parameters and then just get them with ServletConfig.
Or you can have your basic get and set methods so your other classes and set the username and password with them. Also a constructor to set them would work.
Bill
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edit ....\WEB-INF\web.xml file and include your init params. If you change those params in web.xml file after loading your servet engine, the new changes will not come into effect. One time init only.
A related discussion :
http://www.javaranch.com/ubb/Forum7/HTML/001790.html
regds
maha anna

[This message has been edited by maha anna (edited April 20, 2001).]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic