The java code should generate a csv file from the result of a select query.
Say example select * from employee;
. The output of the query should be in csv file in the destination path mentioned in the code.
Please help.
The java code should generate a csv file from the result of a select query.
Say example select * from employee;
. The output of the query should be in csv file in the destination path mentioned in the code.
Please help.
Don't do it in Java. Any decent database already provides builtin facilities for this. It won't be any more efficient in Java than the DB does. Just consult its documentation for export facilities. As you didn't mention which one you're using, I'll just give a MySQL targeted example: LOAD DATA INFILE
.
I'm not sure what your trouble is. Generating CSV files is pretty much trivial in any language that supports file I/O. Parsing CSV files is where things get interesting.
Skaffman made a good comment... you can check out other posts in SO about CSV parsers. For example, check out OpenCSV.