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
Post a Comment