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

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

Description

Convenience method for closing sql objects.

License

Open Source License

Parameter

Parameter Description
rs ResultSet to be closed
st Statement (or subclass) to be closed
conn Connection to be closed

Declaration

public static void closeAll(ResultSet rs, Statement st, Connection conn) throws SQLException 

Method Source Code

//package com.java2s;
/** Copyright (C) (MSA, Inc) All rights reserved.
 ** General Public License: http://www.opensource.org/licenses/gpl-license.php
 **///  ww  w . jav a2  s .  com

import java.sql.*;

public class Main {
    /** Convenience method for closing sql objects. Closing is tried on
     ** all objects, independent of errors/exceptions in previous closes.
     * @param rs ResultSet to be closed
     * @param st Statement (or subclass) to be closed
     * @param conn Connection to be closed
     * @exception SQLException when any problem occurs while closing objects
     */
    public static void closeAll(ResultSet rs, Statement st, Connection conn) throws SQLException {
        try {
            if (rs != null) {
                rs.close();
            }
        } finally {
            try {
                if (st != null) {
                    st.close();
                }
            } finally {
                if (conn != null) {
                    conn.close();
                }
            }
        }
    }
}

Related

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