I'm trying to change an sql query result into csv format then send that to an API for processing.
When I use CSVPrinter (org.apache.commons.csv.CSVPrinter) it always adds: "org.apache.commons.csv.CSVPrinter@5ec70441"
to the output.
I would like to know if it's because of the way I'm using it, or is it a standard thing that I need to parse out first?
This is the code, I tried outputting the CSV a couple ways but get the same thing every time.
public void ScoreTable(String tableName) throws SQLException, IOException {
DataB db = new DataB();
ResultSet rs;
rs = db.executeQuery("SELECT NtNo, SchedDate, SchedTime, Duration, WC, Sequence, CBy FROM " + tableName + " ");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
CSVPrinter csvPrinter;
csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader(rs));
csvPrinter.printRecords(rs);
String scoreCSV = csvPrinter.toString();
System.out.println("String contains: " + scoreCSV);
csvPrinter.close();
populateScore pa = new populateScore();
String theScore = pa.getCsvScore("21", scoreCSV);
System.out.println("API outputs : " + theScore);
}