Java JDBC Connection Close close(Connection conn)

Here you can find the source of close(Connection conn)

Description

close

License

Open Source License

Declaration

public static void close(Connection conn) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    /**//from  w w  w . j  a v a  2 s.  com
     * Close streams (in or out)
     * @param stream
     */
    public static void close(Closeable stream) {
        if (stream != null) {
            try {
                if (stream instanceof Flushable) {
                    ((Flushable) stream).flush();
                }
                stream.close();
            } catch (IOException e) {
                // When the stream is closed or interupted, can ignore this exception
            }
        }
    }

    public static void close(Connection conn) {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                // When the conn is closed or interupted, can ignore this exception
            }
        }

    }

    public static void close(ResultSet rs) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                // When the file is closed already, can ignore this exception
            }
        }
    }

    public static void close(PreparedStatement ps) {
        if (ps != null) {
            try {
                ps.close();
            } catch (SQLException e) {
                // When the file is closed already, can ignore this exception
            }
        }
    }
}

Related

  1. close(Connection con)
  2. close(Connection con)
  3. close(Connection conn)
  4. close(Connection conn)
  5. close(Connection conn)
  6. close(Connection conn)
  7. close(Connection connection)
  8. close(Connection connection)
  9. close(Connection connection)