This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Siva, I can't imagine that there would be a public API to get the password. This would mean that any code with access to a connection or datasource could get the user's credentials. I think you will have more luck intercepting this information from where the connection is created.
If you explain further what you are trying to accomplish, you may get a more useful answer.