Java SQL ResultSet Close closeResultSets(List resultSets)

Here you can find the source of closeResultSets(List resultSets)

Description

Attempts to close a list of SQL result sets.

License

Open Source License

Parameter

Parameter Description
resultSets - List of SQL result sets.

Declaration

public static void closeResultSets(List<ResultSet> resultSets) 

Method Source Code

//package com.java2s;
/*//from   w  w w.ja  va2  s .  com
 * Copyright (C) 2015 Bryan W. Snipes
 * 
 * This file is part of the JDistil web application framework.
 * 
 * JDistil is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JDistil is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with JDistil.  If not, see <http://www.gnu.org/licenses/>.
 */

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

import java.util.List;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    /**
      Class name attribute used in messaging.
    */
    private static String className = "com.bws.jdistil.core.datasource.database.DbUtil";

    /**
      Attempts to close a list of SQL result sets.
      @param resultSets - List of SQL result sets.
    */
    public static void closeResultSets(List<ResultSet> resultSets) {
        if (resultSets != null) {
            for (ResultSet resultSet : resultSets) {
                closeResultSet(resultSet);
            }
        }
    }

    /**
      Attempts to close a SQL result set.
      @param resultSet - SQL result set to close.
    */
    public static void closeResultSet(ResultSet resultSet) {

        // Set method name
        String methodName = "closeResultSet";

        try {
            if (resultSet != null) {
                resultSet.close();
            }
        } catch (SQLException sqlException) {

            // Post error message
            Logger logger = Logger.getLogger("com.bws.jdistil.core.datasource.database");
            logger.logp(Level.SEVERE, className, methodName, "Closing SQL Result Set", sqlException);
        }
    }
}

Related

  1. closeResultSet(ResultSet rs)
  2. closeResultSet(ResultSet rs)
  3. closeResultSetAndStatement(ResultSet rs)
  4. closeResultSetAndStatement(Statement statement, ResultSet resultSet)
  5. closeResultSets(List results)
  6. closeRS(final ResultSet rs)