aspose file tools*
The moose likes JDBC and the fly likes Obtaining User/Password info for DB connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Obtaining User/Password info for DB connections" Watch "Obtaining User/Password info for DB connections" New topic
Author

Obtaining User/Password info for DB connections

Travis Gibson
Ranch Hand

Joined: Oct 17, 2000
Posts: 100
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


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

Joined: Jun 30, 2000
Posts: 1070
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
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Obtaining User/Password info for DB connections
 
Similar Threads
Which solution is the cleanest way to obtain user and password???
why should dataSource be used instead of Device Manager
WAS 4.0 Connection Pool Synchronization
reading properties to get connection
Test connection using FTP