• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

querying for password from java.sql.Connection

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I obtain a Connection object to my Database thru JDBC, where the connection properties come from an external prop file.
I also have to call another java program within my code, passing in the connection details (like dbname, username, password etc.).
I figured out that i can get the user name, dbname, etc from the connection's meta data. But, what I can't manage is to find a way to extract the password detail from the Connection object.

My Questions are:
1. Am I doing the right thing in trying to extract the password details from the Connection object?
2.Is there some other way I can get the password info, in my code (other than accessing the props file)?
Can somebody help me out?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not a good idea to get database connection meta-data .
Instead use the properties file to get a new database connection.

Common database activities like get connection can be put in a static final class.
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be very much worried if you were allowed to get the password information from the Connection. There are definately no methods for doing so in DatabaseMetaData.

Originally posted by Napa Sreedhar:
Common database activities like get connection can be put in a static final class.



Better still, try to learn how to use a javax.sql.DataSource to manage your connections. DataSource(s) can be used both in web and standalone applications, and are the standard J2EE/Java way of managing multiple connections.
 
    Bookmark Topic Watch Topic
  • New Topic