Java SQL ResultSet Close closeAll(Connection conn, Statement stmt, ResultSet rs)

Here you can find the source of closeAll(Connection conn, Statement stmt, ResultSet rs)

Description

close All

License

Apache License

Declaration

static void closeAll(Connection conn, Statement stmt, ResultSet rs) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    static void closeAll(Connection conn, Statement stmt, ResultSet rs) {
        close(rs);/* www . j a  v a 2 s. c o  m*/
        closeAll(conn, stmt);
    }

    static void closeAll(Connection conn, Statement stmt) {
        close(stmt);
        close(conn);
    }

    static void close(Connection conn) {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            //ignore
        }
    }

    static void close(Statement stmt) {
        try {
            if (stmt != null) {
                stmt.close();
            }
        } catch (SQLException e) {
            // ignore
        }
    }

    static void close(ResultSet rs) {
        try {
            if (rs != null) {
                rs.close();
            }
        } catch (SQLException e) {
            // ignore
        }
    }
}

Related

  1. close(ResultSet rs, Statement stmt, Connection con)
  2. close(ResultSet rs, Statement stmt, Connection con)
  3. close(Statement statement, ResultSet resultSet)
  4. closeAll(Connection con, PreparedStatement ps, ResultSet rs)
  5. closeAll(Connection conn, Statement stmt, ResultSet rs)
  6. closeAll(ResultSet rs)
  7. closeAll(ResultSet rs, Statement st, Connection conn)
  8. closeAll(ResultSet rs, Statement stmt, Connection conn)
  9. closeAll(ResultSet rs1, Statement stmt1)