注意:
1.关闭连接顺序:ResultSet-->Statement-->Connection 。
2. 关闭时异常一定要三个分开写try/catch。原因:某个异常不互相影响
if(rs!=null){ //RsultSet rs
rs.close();
}
if(ps!=null){ //PreparedStatement ps
ps.close();
}
if(conn!=null){ //connection conn
conn.close();
}
注意:
1.关闭连接顺序:ResultSet-->Statement-->Connection 。
2. 关闭时异常一定要三个分开写try/catch。原因:某个异常不互相影响
if(rs!=null){ //RsultSet rs
rs.close();
}
if(ps!=null){ //PreparedStatement ps
ps.close();
}
if(conn!=null){ //connection conn
conn.close();
}