Java SQL ResultSet Close close(ResultSet rs, Statement stmt)

Here you can find the source of close(ResultSet rs, Statement stmt)

Description

close

License

Apache License

Declaration

public static void close(ResultSet rs, Statement stmt) 

Method Source Code


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

import java.sql.*;

public class Main {
    public static void close(ResultSet rs, Statement stmt) {
        closeResultSet(rs);//from   w w w .j  a v  a 2s.c o m
        closeStatement(stmt);
    }

    /**
     * Close the given JDBC ResultSet and ignore any thrown exception.
     * This is useful for typical finally blocks in manual JDBC code.
     *
     * @param rs the JDBC ResultSet to close (may be <code>null</code>)
     */
    public static void closeResultSet(ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException ex) {
                //                logger.debug("Could not close JDBC ResultSet", ex);
            } catch (Throwable ex) {
                // We don't trust the JDBC driver: It might throw RuntimeException or Error.
                //                logger.debug("Unexpected exception on closing JDBC ResultSet", ex);
            }
        }
    }

    /**
     * Close the given JDBC Statement and ignore any thrown exception.
     * This is useful for typical finally blocks in manual JDBC code.
     *
     * @param stmt the JDBC Statement to close (may be <code>null</code>)
     */
    public static void closeStatement(Statement stmt) {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException ex) {
                //                logger.debug("Could not close JDBC Statement", ex);
            } catch (Throwable ex) {
                // We don't trust the JDBC driver: It might throw RuntimeException or Error.
                //                logger.debug("Unexpected exception on closing JDBC Statement", ex);
            }
        }
    }
}

Related

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