Exporting MySQL database to excel using java code

Muhammad Salman Farooq picture Muhammad Salman Farooq · Sep 5, 2012 · Viewed 7.8k times · Source

I want to export my MySQL database to .xls or .txt format. How can I do it in java. What I want to do is that there is a button in my application on pressing which, my database export to excel file. Thanks.

Answer

jsj picture jsj · Sep 5, 2012

Make a system call to MySQL:

mysql -e'SELECT * FROM table'>file.csv