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.