java - Operation not allowed after ResultSet closed -


allright been trying figure out last 2 days.

statement statement = con.createstatement();                         string query = "select * sell";                         resultset rs = query(query);                         while (rs.next()){//<--- there operation error here 

this 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 fix error?

it's hard sure code you've posted, suspect resultset inadvertently getting closed (or stm getting reused) inside body of while loop. trigger exception @ start of following iteration.

additionally, need make sure there no other threads in application potentially using same db connection or stm object.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -