站内搜索: 请输入搜索关键词

当前页面: 开发资料首页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();



↑返回目录
前一篇: eclipse中文件前面带叉的图标,是什么意思
后一篇: 新建项目即报错,y?求助