I'm using Xampp for the database in my computer now what i want to do is to back up the database name "HMS" with "root" username and " " password. How can i do this in java please suggest.

Try the following code:

import java.util.*;
import java.io.*;
public class BackUpSql {
    public static void main(String[] args) {
        try {
            Runtime rt = Runtime.getRuntime();
            rt.exec("cmd.exe /c start C:\\ab.bat");
            System.exit(0);
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
    }
}

Here is the ab.bat:

set path=%path%;C:\Program files\MySQL\MySQL Server 5.0\bin;
mysqldump -uroot -proot register > C:\back.sql

where root is the username and password and register is the database.
You have to set the path to bin folder of mysql in the first line of ab.bat correctly.