问题是您 在 读取结果集 之前 已关闭查询。关闭查询,关闭结果集,因此为什么会出现“ ResultSet not
open”错误。您应该在
finally块的最后立即关闭查询:
ResultSet word;Statement query=null;String getData="SELECt THEWORD FROM MAINTAB";try{ System.out.println(dbconn.getAutoCommit()); query = dbconn.createStatement(); word = query.executeQuery(getData); dbconn.setAutoCommit(false); System.out.println(dbconn.getAutoCommit()); for(;word.next();) System.out.println(word.getString(1));}catch(Throwable e){ System.out.println("Table fetch failed or result data failed");} finally{ if(query!=null) { try { query.close(); } catch(SQLException ex) { System.out.println("Could not close query"); } }}


