Java SQL ResultSet Close close(ResultSet rs, Statement ps, Connection conn)

Here you can find the source of close(ResultSet rs, Statement ps, Connection conn)

Description

close

License

Open Source License

Declaration

public static void close(ResultSet rs, Statement ps, Connection conn) 

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 {
    public static void close(ResultSet rs, Statement ps, Connection conn) {
        try {//from   ww w.  j  a va 2s  .co  m
            if (rs != null) {
                rs.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (ps != null) {
                ps.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close(Statement ps, Connection conn) {
        try {
            if (ps != null) {
                ps.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close(Connection conn) {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. close(ResultSet rs)
  2. close(ResultSet rs)
  3. close(ResultSet rs)
  4. close(ResultSet rs, PreparedStatement pstmt, Connection con)
  5. close(ResultSet rs, Statement ps, Connection con)
  6. close(ResultSet rs, Statement st, Connection con)
  7. close(ResultSet rs, Statement st, Connection conn)
  8. close(ResultSet rs, Statement stmt)
  9. close(ResultSet rs, Statement stmt, Connection con)