Pages

Showing posts with label Csv. Show all posts
Showing posts with label Csv. Show all posts

Friday, April 8, 2011

Write Comma Separated Value (CSV) from ResultSet

This code requires the use of the free library java CSV and MyCsvWriter.
. . .
MyCsvWriter csvWriter = new MyCsvWriter("File Name.csv");
try {
      csvWriter.writeColumnNames(rs);
      csvWriter.writeRecords(rs);
      csvWriter.flush();
      csvWriter.close();           
} catch (SQLException e) {
      System.out.println("Oops-> " + e.getMessage());
} catch (IOException e) {
      System.out.println("Oops-> " + e.getMessage());
}
. . .