Java JDBC Collection Transaction rollbackAndClose(Connection con)

Here you can find the source of rollbackAndClose(Connection con)

Description

rollback And Close

License

Open Source License

Declaration

public static void rollbackAndClose(Connection con) throws SQLException 

Method Source Code


//package com.java2s;
/*//from w w w  .j  ava2 s  .  c  o  m
 * $Id$
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

import java.sql.Connection;
import java.sql.SQLException;

public class Main {
    public static void rollbackAndClose(Connection con) throws SQLException {
        if (con != null) {
            if (!con.getAutoCommit()) {
                con.rollback();
            }
            con.close();
        }
    }

    public static void close(Connection con) throws SQLException {
        if (con != null && !con.isClosed()) {
            con.close();
        }
    }
}

Related

  1. rollback(Connection connection)
  2. rollback(Connection connection)
  3. rollback(Connection sqlConn)
  4. rollback(final Connection conn, final Logger logger)
  5. rollback(final Connection connection)
  6. rollbackAndCloseQuietly(Connection conn)
  7. rollbackQuietly(Connection conn)
  8. rollbackQuietly(Connection conn)
  9. rollbackQuietly(Connection connection)