Java JDBC Collection Transaction commit(Connection connection)

Here you can find the source of commit(Connection connection)

Description

Attempts to commit any submitted SQL statements using a given connection.

License

Open Source License

Parameter

Parameter Description
connection - Database connection.

Declaration

public static void commit(Connection connection) 

Method Source Code

//package com.java2s;
/*//from   ww w  .j av  a2  s .c o  m
 * Copyright (C) 2015 Bryan W. Snipes
 * 
 * This file is part of the JDistil web application framework.
 * 
 * JDistil is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * JDistil is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with JDistil.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.sql.Connection;

import java.sql.SQLException;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    /**
      Class name attribute used in messaging.
    */
    private static String className = "com.bws.jdistil.core.datasource.database.DbUtil";

    /**
      Attempts to commit any submitted SQL statements using a given connection.
      @param connection - Database connection.
    */
    public static void commit(Connection connection) {

        // Set method name
        String methodName = "commit";

        try {
            // Check for valid connection and commit type
            if (connection != null && !connection.getAutoCommit()) {

                // Commit any submitted statements
                connection.commit();
            }
        } catch (SQLException sqlException) {

            // Post error message
            Logger logger = Logger.getLogger("com.bws.jdistil.core.datasource.database");
            logger.logp(Level.SEVERE, className, methodName, "Committing SQL Statements", sqlException);
        }
    }
}

Related

  1. commit(Connection conn)
  2. commit(Connection conn)
  3. commit(Connection conn)
  4. commit(Connection conn)
  5. commit(Connection conn)
  6. commitAndClose(Connection conn)
  7. commitAndClose(Connection conn)
  8. commitAndClose(Connection connection)
  9. commitAndClose(Connection connection)