Description
This method releases this PrepareStatement,ResultSet and Connection object's database and JDBC resources.
License
Open Source License
Parameter
Parameter | Description |
---|
prepStmt | a parameter |
rs | a parameter |
con | a parameter |
Exception
Parameter | Description |
---|
SQLException | an exception |
Declaration
public static void closeDatabaseResources(PreparedStatement prepStmt,
ResultSet rs, Connection con) throws SQLException
Method Source Code
//package com.java2s;
/*/*from ww w .j a v a 2 s. co m*/
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Main {
/**
* This method releases this PrepareStatement,ResultSet and Connection
* object's database and JDBC resources.
*
* @param prepStmt
* @param rs
* @param con
* @throws SQLException
*/
public static void closeDatabaseResources(PreparedStatement prepStmt,
ResultSet rs, Connection con) throws SQLException {
if (prepStmt != null) {
prepStmt.close();
}
if (rs != null) {
rs.close();
}
if (con != null) {
con.close();
}
}
/**
* This method releases this Connection and PrepareStatement object's
* database and JDBC resources.
*
* @param prepStmt
* @param con
* @throws SQLException
*/
public static void closeDatabaseResources(PreparedStatement prepStmt,
Connection con) throws SQLException {
if (prepStmt != null) {
prepStmt.close();
}
if (con != null) {
con.close();
}
}
/**
* This method releases this ResutlSet and PrepareStatement object's
* database and JDBC resources.
*
* @param prepStmt
* @param rs
* @throws SQLException
*/
public static void closeDatabaseResources(PreparedStatement prepStmt,
ResultSet rs) throws SQLException {
if (prepStmt != null) {
prepStmt.close();
}
if (rs != null) {
rs.close();
}
}
}
Related
- closeAll(ResultSet rs1, Statement stmt1)
- closeAll(ResultSet rset, Statement stmt, Connection conn)
- closeAllConnections(PreparedStatement preparedStatement, Connection connection, ResultSet resultSet)
- closeConnections(Connection conn, Statement st, ResultSet res)
- closeCursor(Statement stmt, ResultSet rows)
- closeDbObjects(Connection conn, Statement stmt, ResultSet res)
- closeEL(ResultSet rs)
- closeQuietly(Connection conn, Statement stmt, ResultSet rs)
- closeQuietly(Connection conn, Statement stmt, ResultSet rs)