The real problem is that you are sharing Statement objects between multiple threads. Each time you execute the "Statement", the previously returned ResultSet is automatically closed. In this case, the ResultSet objects βbelongβ to another thread that may not have finished using it yet. Hence the exception ...
You cannot pass Connection, Statement / PreparedStatement, or ResultSet objects between multiple threads. Each thread must acquire and release its own resources.
source
share