Java Utililty Methods SQL ResultSet Close

List of utility methods to do SQL ResultSet Close

Description

The list of methods to do SQL ResultSet Close are organized into topic(s).

Method

voidcloseResultset(ResultSet resultset)
close Resultset
try {
    if (resultset != null) {
        resultset.close();
} catch (SQLException e1) {
} catch (Throwable ex) {
voidcloseResultSet(ResultSet resultSet)
close Result Set
if (resultSet != null) {
    resultSet.close();
voidcloseResultSet(ResultSet rs)
close Result Set
try {
    rs.close();
} catch (SQLException e) {
voidcloseResultSet(ResultSet rs)

Closes the given ResultSet.

try {
    if (rs != null) {
        rs.close();
} catch (SQLException e) {
voidcloseResultSet(ResultSet rs)
close Result Set
if (rs != null) {
    try {
        rs.close();
    } catch (SQLException e) {
        throw new RuntimeException(e.getSQLState() + "\nCaused by\n" + e.getCause(), e);
voidcloseResultSet(ResultSet rs)
This will do the clean up of closing an open Statement, ResultSet and Connection if open.
try {
    if (rs != null) {
        Statement s = rs.getStatement();
        rs.close();
        if (s != null) {
            Connection c = s.getConnection();
            s.close();
            if (c != null && !(c.isClosed())) {
...
voidcloseResultSet(ResultSet rs)
close Result Set
try {
    if (null != rs) {
        Statement stmt = rs.getStatement();
        if (null != stmt) {
            stmt.close();
            stmt = null;
        rs.close();
...
voidcloseResultSet(ResultSet rs)
Close resultset and do not throw an exception
try {
    if (rs != null) {
        rs.close();
} catch (SQLException e) {
    logger.error("Exception on closing SQL Result set: " + e.getMessage(), e);
voidcloseResultSet(ResultSet rs)
Close the given JDBC ResultSet and ignore any thrown exception.
if (rs != null) {
    try {
        rs.close();
    } catch (SQLException ex) {
    } catch (Throwable ex) {
voidcloseResultSetAndStatement(ResultSet rs)
close Result Set And Statement
closeResultSet(rs);
try {
    closeStatement(rs.getStatement());
} catch (SQLException e) {