当前页面: 开发资料首页 → Eclipse 专题 → ResultSet问题 ,穷啊只能给1分了,各位高手帮忙看看!
ResultSet问题 ,穷啊只能给1分了,各位高手帮忙看看!
摘要: ResultSet问题 ,穷啊只能给1分了,各位高手帮忙看看!
错误信息:“"ResultSet is closed"” 执行stmt.executeUpdate后rs = null.
public void manageodds() throws SQLException{
try {
String str = null;
String teamid = null;
String teamname = null;
//连接数据库
DbConnect dc = new DbConnect();
Connection conn = dc.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs4 = stmt.executeQuery("select teamid,teamname from Team");
while (rs4.next()){
teamid = rs4.getString("teamid").trim();
teamname = rs4.getString("teamname").trim();
stmt.executeUpdate("update Match set [homeid] = '"+teamid+"' where [home] = '"+teamname+"'");
}
stmt.close();
conn.close();
}
catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
while (rs4.next()){
teamid = rs4.getString("teamid").trim();
teamname = rs4.getString("teamname").trim();
stmt.addBatch("update Match set [homeid] = '"+teamid+"' where [home] = '"+teamname+"'");
}
stmt.executeBatch();
conn.commit();
stmt.close();
conn.close();