This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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.