jyothi
jyothi

Reputation: 11

how to generate a csv file through java code

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.

Upvotes: 0

Views: 6609

Answers (3)

Ascalonian
Ascalonian

Reputation: 15193

Skaffman made a good comment... you can check out other posts in SO about CSV parsers. For example, check out OpenCSV.

Upvotes: 0

T.E.D.
T.E.D.

Reputation: 44814

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.

Upvotes: 0

BalusC
BalusC

Reputation: 1109432

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.

Upvotes: 4

Related Questions