What does it say about moving from row to row in your result set? How many columns do you have?
Who on
earth taught you to indent code like that?
You may only need to use the identifier
buffer once.
Have you been instructed to use the LF character? If not, don't use \n. Use
System.lineSeparator() instead. Why are you using
...+ " " +...? You could simply put the additional space in the preceding
String literal. If you are using a StringBuilder, you would probably do better to use multiple append() calls than use +.