Here you can find the source of closeResultAndStatement(Statement statement, ResultSet resultSet)
Helper method to close the JDBC interface(result set, statement).
Parameter | Description |
---|---|
statement | the statement to be closed, could be null |
resultSet | the result set to be closed, could be null |
Parameter | Description |
---|---|
SQLException | if any error occurs in this method |
public static void closeResultAndStatement(Statement statement, ResultSet resultSet) throws SQLException
//package com.java2s; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { /**//from ww w . ja v a 2s . c om * <p> * Helper method to close the JDBC interface(result set, statement). * </p> * * @param statement the statement to be closed, could be null * @param resultSet the result set to be closed, could be null * @throws SQLException if any error occurs in this method */ public static void closeResultAndStatement(Statement statement, ResultSet resultSet) throws SQLException { try { if (resultSet != null) { resultSet.close(); } } finally { closeStatement(statement); } } /** * <p> * Helper method to close the JDBC interface(statement). * </p> * * @param statement the statement to be closed, could be null * @throws SQLException if any error occurs in this method */ public static void closeStatement(Statement statement) throws SQLException { if (statement != null) { statement.close(); } } }