I am using the following code from the internet to get data from a database:
ResultSet rs = statement.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("querying SELECT * FROM XXX");
int columnsNumber = rsmd.getColumnCount();
while (rs.next()) {
for (int i = 1; i <= columnsNumber; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue + " " + rsmd.getColumnName(i));
}
System.out.println(""); //<-------------
}
Inside the while loop there is the empty println (arrow ^)
If I remove this empty println, the data doesnt show in my console, but if I leave it there it does (I have only one line in my database, so probably it just skips the last line if I have more data).
Why doesnt it show my single line of data if i leave out the empty println???
Thx!