Java SQL ResultSet Close close(Connection connection, PreparedStatement statement, ResultSet resultSet)

Here you can find the source of close(Connection connection, PreparedStatement statement, ResultSet resultSet)

Description

close dataSource

License

Open Source License

Parameter

Parameter Description
connection a parameter
statement a parameter
resultSet a parameter

Declaration

public static void close(Connection connection, PreparedStatement statement, ResultSet resultSet) 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    /**// w  w  w  . j  a  v  a2  s.c om
     * close dataSource
     * @param connection
     * @param statement
     * @param resultSet
     */
    public static void close(Connection connection, PreparedStatement statement, ResultSet resultSet) {
        if (null != resultSet) {
            try {
                resultSet.close();
            } catch (SQLException e) {
                System.err.println("close resultset error!");
            }
        }

        if (null != statement) {
            try {
                statement.close();
            } catch (SQLException e) {
                System.err.println("close statement error!");
            }
        }

        if (null != connection) {
            try {
                connection.close();
            } catch (SQLException e) {
                System.err.println("close connection error!");
            }
        }
    }
}

Related

  1. close(Connection c, Statement s, ResultSet r)
  2. close(Connection con, Statement stmt, ResultSet rs)
  3. close(Connection conn, PreparedStatement ps, ResultSet rs)
  4. close(Connection conn, Statement st, ResultSet rs)
  5. close(Connection conn, Statement st, ResultSet rs)
  6. close(Connection connection, Statement statement, ResultSet resultSet)
  7. close(final PreparedStatement ps, final ResultSet rs)
  8. close(final ResultSet rs, final Statement st)
  9. close(ResultSet _rsData, Logger _logger)