0

How import and export .sql file by query. notice Using in jdbc

Amr Emaish
  • 177
  • 1
  • 10
  • Are you asking about creating and loading an SQL dump file? If so, then the simple way is to use the database's sql dump / restore utilities, not JDBC. Just call it using the `Process` class. – Stephen C Nov 07 '15 at 07:06
  • I want to store my data in my drive D or E by java app . I'm afraid of losing my data – Amr Emaish Nov 07 '15 at 07:13
  • And I have not more experience in Sql to do that – Amr Emaish Nov 07 '15 at 07:14

1 Answers1

2

The importing part of your question has already been asked here "How to execute .sql script file using JDBC"

To do exporting you need to create a SQL queries to get data from every table in your database. Then write that data out to a file.

Your task of exporting data would be more simple using sql dump utilities, or MYSQL workbench.

Do export a single database via command line you can do this:

$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql

More command line options for SQL can be found here: "MySQL: How to export and import an .sql file from command line?"

Community
  • 1
  • 1
Whitecat
  • 3,882
  • 7
  • 48
  • 78