Here you can find the source of close(ResultSet rs, Statement stmt, Connection con)
Parameter | Description |
---|---|
ResultSet | a parameter |
Statement | a parameter |
Connection | a parameter |
public static void close(ResultSet rs, Statement stmt, Connection con)
//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 { /**//from ww w . j a va2s . co m * Utility function for safely closing open resultset/statement/connection * * @param ResultSet * @param Statement * @param Connection */ public static void close(ResultSet rs, Statement stmt, Connection con) { if (rs != null) { try { rs.close(); } catch (SQLException e) { System.out.println("The result set cannot be closed."); } } if (stmt != null) { try { stmt.close(); } catch (SQLException e) { System.out.println("The statement cannot be closed."); } } if (con != null) { try { con.close(); } catch (SQLException e) { System.out.println("The data source connection cannot be closed."); } } } }