Convert Resultset to CSV file using Java

后端 未结 2 1552
独厮守ぢ
独厮守ぢ 2021-01-06 21:26

Hi I am trying to convert oracle jdbc resultset to csv file. Below is the code used. Issue occures when there is value like below in the field. It deforms the output csv and

2条回答
  •  礼貌的吻别
    2021-01-06 21:34

    Are you using "java.sql.ResultSet" class? If yes, see the library in this link http://opencsv.sourceforge.net/

    See an example:

    CSVWriter csvWriter = new CSVWriter(new FileWriter("yourfile.csv"), '\t');
    java.sql.ResultSet myResultSet = .... ;
    csvWriter.writeAll(myResultSet, includeHeaders);
    

提交回复
热议问题