Java JDBC Connection Close close(Connection conn)

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

Description

close

License

Apache License

Declaration

public static void close(Connection conn) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Main {
    public static void close(Connection conn, PreparedStatement pstmt, ResultSet result) {
        //close connections.
        if (result != null) {
            try {
                result.close();/*from   www  .j  a  v a2s.  c o  m*/
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(Connection conn, PreparedStatement pstmt) {
        //close connections.
        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(Connection conn) {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

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)