I have a
ResultSet rs = sql.getData(con, query);
with two columns and several rows. I want to get the data as a output in a JSON style output like:
x: [1, 2, 3, 4],
y: [2.37, 2.16, 4.82, 1.73],
So, I want first the data of column1 written to the first line "x" and then the second column2 to y.
All documentation I find about iterating the data of a resultset is row-wise like for the HTML table output like
while (rs.next()) {
out.append("<tr>");
for (int col = 1; col < rsMeta.getColumnCount() + 1; col++) {
out.append("<td>");
out.append(rs.getString(col));
out.append("</td>");
}
out.append("</tr>");
cnt++;
}