Operation not allowed after ResultSet closed
java, resultset, select, sql
Solution
It's hard to be sure just from the code you've posted, but I suspect that the `ResultSet` is inadvertently getting closed (or `stm` is getting reused) inside the body of the `while` loop. This would trigger the exception at the start of the following iteration.
Additionally, you need to make sure there are no other threads in your application that could potentially be using the same DB connection or `stm` object.
Problem
Allright been trying to figure this out the last 2 days. ``` Statement statement = con.createStatement(); String query = "SELECT * FROM sell"; ResultSet rs = query(query); while (rs.next()){//<--- I get there operation error here ``` This is the query method. ``` public static ResultSet query(String s) throws SQLException { try { if (s.toLowerCase().startsWith("select")) { if(stm == null) { createConnection(); } ResultSet rs = stm.executeQuery(s); return rs; } else { if(stm == null) { createConnection(); } stm.executeUpdate(s); } return null; } catch (Exception e) { e.printStackTrace(); con = null; stm = null; } return null; } ``` How can I fix this error?