0

I have a java project and placed sql file(backup) in this project.
how to Restore this file inside library to mysql with java(Restore of jar file)?

1

2 Answers 2

1

Is this against a remote server? If you are not opposed to combining Java with the MySQL command line client then you can just do:

Runtime.getRuntime().exec("/usr/bin/mysql <your connection options> < your_sql_backup.sql");

If you want it all native Java then you'll end up needing to parse your sql backup and execute the queries through JDBC.

Sign up to request clarification or add additional context in comments.

Comments

0

Run mysql -uUSERNAME -pPASWORD SCHEMA <yourfile.sql. You can use either Runtime.getRuntime().exec() or ProcessBuilder to execute external program.

The mysql command requires redirect to restore data. You can either create shell script/batch file (depending on your operating system) and run it from java or run command line like cmd /c mysql... or /bin/sh mysql directly from java application (again, depending on your OS)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.