Difference between revisions of "Write a SQL result set to a comma seperated value (CSV) file"

From CodeCodex

 
m
 
Line 15: Line 15:
 
[[Category:I/O]]
 
[[Category:I/O]]
 
[[Category:CSV]]
 
[[Category:CSV]]
[[Category:MySQL]]
+
[[Category:SQL]]

Latest revision as of 22:06, 1 January 2007

Implementations[edit]

Java[edit]

This code requires the use of the free library OpenCSV.

CSVWriter writer = new CSVWriter(new FileWriter("yourfile.csv"), '\t');

java.sql.ResultSet myResultSet;

//set myResultSet to the results of your query here

writer.writeAll(myResultSet, includeHeaders);