Java SQL ResultSet Close close(Connection con, Statement stmt, ResultSet rs)

Here you can find the source of close(Connection con, Statement stmt, ResultSet rs)

Description

close

License

Open Source License

Declaration

public static void close(Connection con, Statement stmt, ResultSet rs) 

Method Source Code


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

import java.sql.Connection;

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

public class Main {
    public static void close(Connection con, Statement stmt, ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();//from ww w .ja  v a2s. co  m
            } catch (SQLException e) {
                System.out.println("5--SQLException");
                e.printStackTrace();
            }
        }
        if (stmt != null) {
            try {
                stmt.close();
            } catch (SQLException e) {
                System.out.println("6-SQLException");
                e.printStackTrace();
            }
        }
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
                System.out.println("7-closeSQLException");
                e.printStackTrace();
            }
        }
    }

    public static void close(Connection con, PreparedStatement pstmt, ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                System.out.println("8-SQLException");
                e.printStackTrace();
            }
        }
        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (SQLException e) {
                System.out.println("9-SQLException");
                e.printStackTrace();
            }
        }
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
                System.out.println("10-closeSQLException");
                e.printStackTrace();
            }
        }
    }

    public static void close(Connection con) {
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
                System.out.println("11-closeSQLException");
                e.printStackTrace();
            }
        }
    }
}

Related

  1. close(Connection c, Statement s, ResultSet r)
  2. close(Connection conn, PreparedStatement ps, ResultSet rs)
  3. close(Connection conn, Statement st, ResultSet rs)
  4. close(Connection conn, Statement st, ResultSet rs)
  5. close(Connection connection, PreparedStatement statement, ResultSet resultSet)