• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Obtaining Database password

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic