Message-ID: From: "butopcu (@butopcu)" To: "pgjdbc/pgjdbc" Date: Wed, 18 Dec 2024 19:25:15 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3462: Next Method of PgResultSet Throws NullPointerException Instead of SQLException In-Reply-To: References: List-Id: X-GitHub-Author-Login: butopcu X-GitHub-Comment-Id: 2552103859 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2024-12-18T19:31:19Z X-GitHub-Issue: 3462 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3462#issuecomment-2552103859 Content-Type: text/plain; charset=utf-8 @vlsi Actually, each thread uses new `ResultSet` and `Statement` objects as these are local variables. Our Database Team has thoroughly investigated the code and PostgreSQL logs but couldn't determine why the `ResultSet` occasionally and rarely switches to a closed state. The same SQL queries are being executed with different parameters across multiple threads: **Thread 1**: - Integers: `WHERE IN (1..500)` (Main SQL Query to TableA) - The `ResultSet` remains open (`TYPE_SCROLL_INSENSITIVE`). - Process all data in a loop: - `WHERE = ID` (Subquery to TableB for each entry returned from TableA). (New ResultSet, Connection and Statement) **Thread 2**: - Integers: `WHERE IN (501..1000)` (Main SQL Query to TableA). - Process all data in a loop: - `WHERE = ID` (Subquery to TableB for each entry returned from TableA). The only static object is the SQL query string, such as: `private static final String QUERY_BY_ID= "SELECT name, adress FROM TABLEB WHERE ID=?";`