| Author |
Obtaining Database password
|
Anirudh Vyas
Ranch Hand
Joined: Oct 23, 2006
Posts: 93
|
|
Hi, I am trying to do dataSourceInstance.getConnection().getMetaData( ) and i see only getUserName( ), getConnectionURL( ). I do not however see a getPassword( ); is there any way i can obtain database password at runtime? For curious, i need to pass the user name and password into some external library method that uses it. Any help in this regard would be appreciable. Regards Vyas, Anirudh
|
Vyas, Anirudh
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
A password is a sort of write-only attribute. You enter it and it is hashed with MD5 or similar, then you cannot retrieve it.
|
 |
Anirudh Vyas
Ranch Hand
Joined: Oct 23, 2006
Posts: 93
|
|
Well; it begs the question doesn't it? connection URL can contain the user name and password; you could parse the connection URL to retrieve password; but that solution is *Yuk!* (which would be my final stab at it). Any other suggestions? I could save user and pwd info in properties file, but dont wanna do that; because if i do that, now i got so many things to worry about, because a data source is gotten by service locator using JNDI lookup; The data source aligns with data source used by application throughout. Now if i change something i gotta go and change this properties file up there ... Regards Vyas, Anirudh
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26195
|
|
Originally posted by Anirudh Vyas: Well; it begs the question doesn't it? connection URL can contain the user name and password; you could parse the connection URL to retrieve password
Only if you pass the password that way. Most people don't for security reasons. I recommend putting the password somewhere you can get to it. Preferably in an encrypted property file. This is preferable than the program trying to parse it as nobody can get their hands on the actual password.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Obtaining Database password
|
|
|