在非自动事务模式下,即AutoCommit=false时,stmt一定要关闭,否则同一个连接只能用一次,多次使用时会报 Cannot Start a Cloned Connection While in Manual Transaction Mode 错误。养成良好的编程习惯对于系统的稳定和健壮性是很重要的。
to ningIII(小宁):如果关闭连接,那么记录集肯定还是存在的。-------------严重错误 连接关闭掉,结果集则不存在,resultset对象是要保持连接的状态下才有用的.
to ningIII(小宁):如果关闭连接,那么记录集肯定还是存在的。-------------严重错误 连接关闭掉,结果集则不存在,resultset对象是要保持连接的状态下才有用的.
if(rs != null){
try{rs.close()}catch(Exception e){}
}
if(state != null){
try{state.close()}catch(Exception e){}
}
if(conn != null){
try{conn.close()}catch(Exception e){}
}
con.close();
关闭与数据库的连接,并释放Connection对象几该连接占用的相关资源。
rs.close();
释放ResultSet对象所占用的资源。
stmt.close();
释放该Statement对象占用的资源。从以上的解释看来还是要关闭才不会浪费资源。
连接关闭掉,结果集则不存在,resultset对象是要保持连接的状态下才有用的.
连接关闭掉,结果集则不存在,resultset对象是要保持连接的状态下才有用的.
if(rs != null){
try{rs.close()}catch(Exception e){}
}
if(state != null){
try{state.close()}catch(Exception e){}
}
if(conn != null){
try{conn.close()}catch(Exception e){}
}