Restore MySql DB on Windows using Java

MYSQl is the world’s second most widely used open-source relational database management system. MYSQL RDBMS provides the mysql shell to restore the database, We can invoke the mysql command from command Prompt to restore the database, mysql shell can also be invoked from java using the java.lang.Runtime class.
In the example we are going to restore the database using java.lang.RunTime class.

To run this program create java Project —> create package(com.javaartifacts) —> create class RestoreDbFile(Copy and paste above code in class file) —> download and paste the mysql jar in lib file

In the Program We are first creating the database by executing the query using the jdbc api.
For succesfully execution we have to set the path of mysql.exe path in Environment variable or supply the full path of mysql.exe.
If there is space in between the directory Path as shown below then we have to supply the full path in double quotes like "\"C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysql.exe\"" in the restoreDB method.