I've never used SQLite so don't know if the following points have any bearing on your problem:
1. The point of prepared statements is you "make them once and use them many times" so you should create the prepared statements outside the loops
2. Your select statement is never closed as you reuse the pstmt variable in the result set loop. Similarly all the statements created in the result set loop, except for the last one, will never be closed.
3. ResultSets are only automatically closed if the statement that generated them is closed or re-executed. Most of your statements are never closed and none are re-executed so you aren't closing most of the ResultSets.
4. Statements should be closed in a finally clause to make sure they are always closed.
You probably need to do what I said in my earlier post ie make sure you close every statements object you create.
The best thing is to move your create prepared statements code outside of the loops, assign them to separate variables, add a finally clause to your inner try statement and call close() on both statement variables in the finally clause.