Here you can find the source of closeResultSet(ResultSet rs)
Parameter | Description |
---|---|
rs | the JDBC ResultSet to close (may be <code>null</code>) |
public static void closeResultSet(ResultSet rs)
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { /**//w ww. ja v a2 s. c o m * Close the given JDBC ResultSet and ignore any thrown exception. * This is useful for typical finally blocks in manual JDBC code. * * @param rs the JDBC ResultSet to close (may be <code>null</code>) */ public static void closeResultSet(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException ex) { // logger.debug("Could not close JDBC ResultSet", ex); } catch (Throwable ex) { // We don't trust the JDBC driver: It might throw RuntimeException or Error. // logger.debug("Unexpected exception on closing JDBC ResultSet", ex); } } } public static void close(ResultSet rs, Statement stmt) { closeResultSet(rs); closeStatement(stmt); } /** * Close the given JDBC Statement and ignore any thrown exception. * This is useful for typical finally blocks in manual JDBC code. * * @param stmt the JDBC Statement to close (may be <code>null</code>) */ public static void closeStatement(Statement stmt) { if (stmt != null) { try { stmt.close(); } catch (SQLException ex) { // logger.debug("Could not close JDBC Statement", ex); } catch (Throwable ex) { // We don't trust the JDBC driver: It might throw RuntimeException or Error. // logger.debug("Unexpected exception on closing JDBC Statement", ex); } } } }