As the title states, I'm exporting a java query from a local database into a CSV file, all the required information prints out correctly, however my column headers Print out in Column A (row 1-8) and not along columns (A-H). in short i have headers 1-8 printing in column 1, followed by thousands of rows of data in the correct order. Pretty new to java, sorry if I'm being silly!
PrintWriter out = new PrintWriter(new BufferedWriter(
new FileWriter("TestingRawData.csv")));
ResultSetMetaData rsmd = result.getMetaData();
int columnCount = rsmd.getColumnCount();
for (int i = 1; i < columnCount + 1; i++) {
String name = rsmd.getColumnName(i);
out.println(name);
// print the name
}
while (result.next()) {
out.println(String.format("%s,%s,%s,%s,%s,%s,%s,%s",
result.getString(1), result.getString(2),
result.getString(3), result.getString(4),
result.getString(5), result.getString(6),
result.getString(7), result.getString(8)));
}