日期:2014-05-18 浏览次数:20723 次
finally {
try {
rs.close();
pstmt.close();
rs2.close();
pstmt2.close();
rs3.close();
pstmt3.close();
rs4.close();
pstmt4.close();
rs5.close();
pstmt5.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
private void CloseStatement(Statement ...st){
for (int i = 0; i < st.length; i++) {
if(st[i]!=null){
try {
st[i].close();
} catch (SQLException e) {
System.out.println("关闭Statement失败");
}
}
}
}
/**
* 参数顺序 ResultSet,然后Statement,最后Connection
* @param objs
*/
public static void close(Object ...objs)
{
for(int i = 0; i < objs.length; ++i)
{
if(objs[i] instanceof Statement)
{
try{
((Statement)objs[i]).close();
}catch(SQLException e){
}
}else if(objs[i] instanceof ResultSet){
try{
((ResultSet)objs[i]).close();
}catch(SQLException e){
}
}else if(objs[i] instanceof Connection){
try{
((Connection)objs[i]).close();
}catch(SQLException e){
}