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
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);
Get the value for the column that could have new lines as
String multiLine = null;
if (k == <col_index> && (mutiLine = rs.getString(k)) != null)
out.append(multiLine.replaceAll("\\n", ""));
else
out.append(result.getString(k));
You could filter all the columns as well but then would incur some performance hit.