Java SQL PreparedStatement closePS(PreparedStatement argPreparedStatement)

Here you can find the source of closePS(PreparedStatement argPreparedStatement)

Description

Closes the given prepared statement.

License

Open Source License

Parameter

Parameter Description
argPreparedStatement a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static void closePS(PreparedStatement argPreparedStatement) throws Exception 

Method Source Code

//package com.java2s;
/**//from ww w.j a v  a  2s. c o  m
 * Project: JLIB
 * Version: $Id$ 
 * License: (see below block, or the accompanied COPYING.txt file)
 **************************************************************************************** LICENSE BEGIN *****
 * Copyright (c) 2009-2013, JLIB AUTHORS (see the AUTHORS.txt file for the list of the individuals)
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided 
 * that the following conditions are met:
 * 
 *  1) Redistributions of source code must retain the above copyright notice, this list of conditions and the 
 *     following disclaimer.
 *  2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
 *     the following disclaimer in the documentation and/or other materials provided with the distribution.
 *  3) Neither the names of the organisations involved in the JLIB project, nor the names of their 
 *     contributors to the JLIB project may be used to endorse or promote products derived from this software 
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************************** LICENSE END *****
 * 
 * This file is best viewed with 110 columns.
12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
 * 
 * In chronological order
 * Author(s):
 *   Dejan Lekic , http://dejan.lekic.org
 * Contributor(s):
 *   -
 */

import java.sql.Connection;

import java.sql.PreparedStatement;

public class Main {
    /**
     * Closes the given prepared statement.
     * 
     * @param argPreparedStatement
     * @throws Exception 
     */
    public static void closePS(PreparedStatement argPreparedStatement) throws Exception {
        if (argPreparedStatement != null) {
            argPreparedStatement.close();
        }
    }

    /**
     * Closes all given PreparedStatement objects.
     * 
     * @param argPreparedStatements
     * @throws Exception 
     */
    public static void closePS(PreparedStatement... argPreparedStatements) throws Exception {
        for (PreparedStatement ps : argPreparedStatements) {
            closePS(ps);
        } // foreach
    }

    /**
     * Closes the given SQL Connection.
     * 
     * @param argConnection
     * @throws Exception 
     */
    public static void close(Connection argConnection) throws Exception {
        if (argConnection != null) {
            argConnection.close();
        }
    }

    public static void close(Connection... argConnections) throws Exception {
        for (Connection con : argConnections) {
            close(con);
        } // foreach
    }
}

Related

  1. close(PreparedStatement preparedStatement)
  2. close(PreparedStatement stat)
  3. closePreparedStatement(Map psMap)
  4. closePreparedStatement(PreparedStatement pstmt)
  5. closePreparedStatement(Statement ps)
  6. closeSilentlyPreparedStatement(PreparedStatement stmt)
  7. closeStatement(PreparedStatement preparedStatement)
  8. closeStatement(PreparedStatement ps)
  9. closeStatement(PreparedStatement theStatement)