我看了很多答案,但不幸的是没有回答我的问题,我仍然无法弄清楚为什么我得到ResultSet closed
。java.sql.SQLException:结果集关闭sqlite
这里是try
代码片段that`s导致了问题:
System.out.println(" System Info! @CHKMD5Files(): Found pre-existing details: "+TOTAL);
Statement stmMD5 = null;
Connection connMD5 = null;
ResultSet rs_MD5 = null;
String RESULTMD5 = null;
try {
connMD5 = DriverManager.getConnection("jdbc:sqlite:" + bkpPATH+ hostname + ".db");
stmMD5 = connMD5.createStatement();
connMD5.setAutoCommit(false);
while (ROWID <= TOTAL) {
rs_MD5 = stmMD5.executeQuery("SELECT md5 FROM details WHERE ROWID = '"+ROWID+"';");
RESULTMD5 = rs_MD5.getString("MD5");
skipBuffer.write(RESULTMD5);
skipBuffer.newLine();
skipBuffer.flush();
ROWID++;
}
System.out.println(" System Info! @CHKMD5Files(): Done with try");
} catch (Exception ex) {
System.out.println(" System Error! @CHKMD5Files (2): " + ex);
System.exit(5);
} finally {
if (stmMD5 != null){
stmMD5.close();
System.out.println(" System Info! @CHKMD5Files (2): Closing Statement(stmMD5)");
}
if (connMD5 != null) {
connMD5.close();
System.out.println(" System Info! @CHKMD5Files (2): Closing Connection(connMD5)");
}
skipBuffer.close();
}
}
貌似while循环甚至不运行,因为如果我把打印语句在循环返回任何内容。
在什么时候,你得到这个错误? –
你可以添加错误的堆栈跟踪?这会有很大的帮助 –
“看起来while循环甚至没有运行,因为如果我把循环印出的东西没有返回。”这意味着ROWID变量会给你带来问题。所以把它的代码。即将结果存储在ROWID中的查询部分。 –