conn,stmt,rset 的关闭(规范)

     Connection conn = null;
        Statement stmt = null;
        ResultSet rset = null;

        try {
            conn = dataSource.getConnection();
            stmt = conn.createStatement();
            rset = stmt.executeQuery("select 1 from dual");
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
             try { if (rset != null) rset.close(); } catch(Exception e) { }
             try { if (stmt != null) stmt.close(); } catch(Exception e) { }
             try { if (conn != null) conn.close(); } catch(Exception e) { }
        }
原文地址:https://www.cnblogs.com/zno2/p/4566439.html