i am new to java ,i am trying some example on JDBC but if i want to connect to database i need to mention username and password of my database so ,how to avoid hardcoded password and username in JDBC connection
I think you misunderstood. Shakuntala is talking about the username / password to use to connect to the database in the first place.
They need to be stored in some external way; a resource file inside the JAR file, a configuration file (preferably using XML or java.util.Properties), the Windows registry (using a third party library or java.util.prefs.Preferences), etc.
Eventually in order to make it configurable, password must be in some properties/xml file. I suggest you can keep it in an encoded form in a properties file. You can decode the same in your Java code while making a DB connection