Java SQL ResultSet Close closeConnections(Connection conn, Statement st, ResultSet res)

Here you can find the source of closeConnections(Connection conn, Statement st, ResultSet res)

Description

close Connections

License

Open Source License

Parameter

Parameter Description
conn a parameter
st a parameter
res a parameter

Exception

Parameter Description
SQLException an exception

Declaration

private static void closeConnections(Connection conn, Statement st, ResultSet res) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;

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

public class Main {
    /**//from   ww  w.j  a  v a  2s. co  m
     * @param conn
     * @param st
     * @param res
     * @throws SQLException
     */
    private static void closeConnections(Connection conn, Statement st, ResultSet res) throws SQLException {
        if (res == null)
            throw new IllegalArgumentException("Trying to close a null result set.");

        res.close();
        closeConnections(conn, st);
    }

    /**
     * @param conn
     * @param st
     * @throws SQLException
     */
    private static void closeConnections(Connection conn, Statement st) throws SQLException {
        if (st == null)
            throw new IllegalArgumentException("Trying to close a null statement.");
        else
            st.close();
        if (conn == null)
            throw new IllegalArgumentException("Trying to close a null connection.");
        else
            conn.close();
    }
}

Related

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