How to export data from the database into .csv format programmatically?

csv, database, java, mysql

Solution

I used this once it worked for me. http://opencsv.sourceforge.net/

Honestly, unless you want to do something fancy, what you are doing should work

Problem

I have stored some data in MySQL database through a java program. Now I want to export that data from the same program in .csv file. I know One method of doing this is to get all the fields of one row in variables and then store them in a file by seperating them with a comma(,) and by repeating the same for every row in the database. But I want to know that Can I export the same data through any other way through java in .csv format.

Original source