Java SQL ResultSet Close closeAll(ResultSet rs)

Here you can find the source of closeAll(ResultSet rs)

Description

close All

License

Apache License

Declaration

public static void closeAll(ResultSet rs) 

Method Source Code

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

import java.sql.Connection;

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

public class Main {
    public static void closeAll(ResultSet rs) {
        Statement stmt = null;/*w  ww. j  a va  2 s .  c  o  m*/
        Connection conn = null;
        try {
            stmt = rs.getStatement();
            conn = stmt.getConnection();

        } catch (SQLException e) {

        } finally {
            closeResultSet(rs);
            closeStatement(stmt);
            closeConnection(conn);
        }
    }

    public static void closeResultSet(ResultSet rs) {
        try {
            rs.close();
        } catch (SQLException e) {

        }
    }

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

            }
        }
    }

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

            }
        }
    }
}

Related

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