Skip to content
Advertisement

How to display a SQL Query that returns multiple rows in Java

So I have a SQL Query that returns multiple rows and columns of information but I am having trouble displaying more than a single row in a textArea. The code below correctly displays the first row of information but I’m not sure how I could get it to also display the other 4 rows of information.

Here is what the SQL command returns (https://imgur.com/a/odkoCpr)

The textarea is showing only the first row (https://imgur.com/a/mNHf9nZ)

Advertisement

Answer

You are using carid2 in the same while loop which means the cursor is still at record number 1. This code is not correct. You can do something like setting all values in a string builder and finally appending it with more records.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement