so i've been looking around problem , seems problem arises when statement tries multiple resultsets.
but in following code exception, though executeupdate returns int.
resultset resultsrs = statement.executequery("select distinct snum shipments quantity >= 100"); int rowcount=0; while(resultsrs.next()){ statement.executeupdate("update suppliers set status = status + 5 snum = "+"\""+resultsrs.getstring(1)+"\""); rowcount++; }
it runs 1 time fine, after gives exception. how able fix this?
all execution methods in statement interface implicitly close statment's current resultset. see docs need store resultset data in temporary array , loop through it.
or try use statement executeupdate.
try this:
arraylist<string> tmp = new arraylist<string>(); while(resultsrs.next()){ tmp.add(resultsrs.getstring(1)); } (string s: tmp) { statement.executeupdate("update suppliers set status = status + 5 snum = "+"\""+s+"\""); rowcount++; }
Comments
Post a Comment