JDBC,关闭资源,按获取顺序倒序关闭

/**
 * 关闭资源,按获取顺序倒序关闭
 */
public static void closeAll(AutoCloseable... closeables) {
    for (AutoCloseable closeable : closeables) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (Throwable ignored) {
        }
    }
}

 

posted @ 2023-03-29 10:44  丶Ronnie  阅读(39)  评论(0)    收藏  举报