JDBC——释放资源的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public static void release(ResultSet rs, Statement statement,
            Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (statement != null) {
            try {
                statement.close();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
 
    }

 

posted @   蔡蔡的弱鸡  阅读(472)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示