首页 > 其他 > 详细

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

时间:2016-08-06 08:17:05      阅读:106      评论:0      收藏:0      [点我收藏+]

 

     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) { }
        }

 

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

原文:http://www.cnblogs.com/zno2/p/4566439.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!