Does the error get thrown the first time through the loop, or after several iterations? One potential problem is that you are creating multiple "Statement" instances inside of the "for(...)" loop, but you are only closing one in the "finally" clause. This is a case where you'll need to close the statement inside of the loop (do it inside of a separate try/catch block). You may be running out of resources if you create too many statement instances.