Java SQL ResultSet Close closeResources(Connection conn, Statement pstmt, ResultSet rs)

Here you can find the source of closeResources(Connection conn, Statement pstmt, ResultSet rs)

Description

close Resources

License

Apache License

Declaration

public static void closeResources(Connection conn, Statement pstmt, ResultSet rs) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.*;

public class Main {

    public static void closeResources(Connection conn, Statement pstmt, ResultSet rs) {
        if (null != rs) {
            try {
                rs.close();//from  w w w .  j a v a  2  s .co m
            } catch (SQLException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            } finally {
                if (null != pstmt) {
                    try {
                        pstmt.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    } finally {
                        if (null != conn) {
                            try {
                                conn.close();
                            } catch (SQLException e) {
                                e.printStackTrace();
                                throw new RuntimeException(e);
                            }
                        }
                    }
                }
            }
        }
    }
}

Related

  1. closeQuietly(ResultSet res)
  2. closeQuietly(ResultSet resultSet)
  3. closeQuietly(ResultSet resultSet)
  4. closeQuietly(ResultSet rs)
  5. closeResource(Connection conn, Statement stmt, ResultSet rs)
  6. closeResources(Connection conn, Statement stmt, ResultSet rs)
  7. closeResources(Connection conn2, Statement statement, ResultSet rs)
  8. closeResultAndStatement(Statement statement, ResultSet resultSet)
  9. closeResultSet(final ResultSet resultSet)