I am using jdbc connection to a database and getting multiple rows as part of the ResultSet. I run a sql off of the ResultSet and somehow end up only going through the first row. For eg: query1 is my result set that generates two pid rows. I then use query2 to terminate the pid. I would like query2 to go through all the rows in query1 and execute the terminate command one after the other. Another point to note is that query1 can have more than 2 rows depending on the resultset. Below is code I am using and any help is appreciated. BTW I did try using a nested for loop in while and that does not reissue query2 as I see in the database logs.