Here you can find the source of closeResources(Connection conn2, Statement statement, ResultSet rs)
public static void closeResources(Connection conn2, Statement statement, ResultSet rs)
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static void closeResources(Connection conn1, PreparedStatement pstmt, ResultSet rs) { if (null != rs) { try { rs.close();//from w w w . j a va 2 s. co m } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { if (null != pstmt) { try { pstmt.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { if (null != conn1) { try { conn1.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } } } } } } } public static void closeResources(Connection conn2, Statement statement, ResultSet rs) { if (null != rs) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { if (null != statement) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { if (null != conn2) { try { conn2.close(); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException(e); } } } } } } } }