Here you can find the source of closeQuietly(Connection conn, Statement stmt, ResultSet rs)
Parameter | Description |
---|---|
conn | Connection . |
stmt | Statement . |
rs | ResultSet . |
public static void closeQuietly(Connection conn, Statement stmt, ResultSet rs)
//package com.java2s; /**/*from w w w .j a v a2 s. c o m*/ * Copyright 2013 Jee Vang Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; public class Main { /** * Quietly closes JDBC objects (exceptions are swallowed). * @param conn {@link Connection}. * @param stmt {@link Statement}. * @param rs {@link ResultSet}. */ public static void closeQuietly(Connection conn, Statement stmt, ResultSet rs) { if (null != rs) { try { rs.close(); rs = null; } catch (Exception ex) { } } if (null != stmt) { try { stmt.close(); stmt = null; } catch (Exception ex) { } } if (null != conn) { try { conn.close(); conn = null; } catch (Exception ex) { } } } }