The code you show does *not* present a problem, in other words, it doesn't need finish(). You don't break out of the while loops, which means you do fetch all rows and therefore finish() is called automatically. The only time you need finish is if you fetch less than all rows e.g. you call one of the fetch methods outside of a loop, or if you call it in a loop but break out of the loop before all rows are fetched.