Java SQL ResultSet Close closeCursor(Statement stmt, ResultSet rows)

Here you can find the source of closeCursor(Statement stmt, ResultSet rows)

Description

close Cursor

License

Open Source License

Declaration

public static List<String> closeCursor(Statement stmt, ResultSet rows) 

Method Source Code

//package com.java2s;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> closeCursor(Statement stmt, ResultSet rows) {
        List<String> exceptions = new ArrayList<String>();

        try {//from   www.ja v  a  2 s.co m
            if (rows != null)
                rows.close();
        } catch (SQLException e) {
            // During hard-close it's acceptable to just
            // log the message.
            //
            // Save the message with the intention of logging
            // it from the caller.
            exceptions.add(e.getMessage());
        }
        try {
            if (stmt != null)
                stmt.close();
        } catch (SQLException e) {
            // During hard-close it's acceptable to just
            // log the message.
            //
            // Save the message with the intention of logging
            // it from the caller.
            exceptions.add(e.getMessage());
        }

        return exceptions;
    }
}

Related

  1. closeAll(ResultSet rs, Statement stmt, Connection conn)
  2. closeAll(ResultSet rs1, Statement stmt1)
  3. closeAll(ResultSet rset, Statement stmt, Connection conn)
  4. closeAllConnections(PreparedStatement preparedStatement, Connection connection, ResultSet resultSet)
  5. closeConnections(Connection conn, Statement st, ResultSet res)
  6. closeDatabaseResources(PreparedStatement prepStmt, ResultSet rs, Connection con)
  7. closeDbObjects(Connection conn, Statement stmt, ResultSet res)
  8. closeEL(ResultSet rs)
  9. closeQuietly(Connection conn, Statement stmt, ResultSet rs)