set Connection Auto Commit - Java java.sql

Java examples for java.sql:Transaction

Description

set Connection Auto Commit

Demo Code


//package com.java2s;
import java.sql.Connection;

import java.sql.SQLException;

public class Main {
    public static Boolean setAutoCommit(Connection conn,
            boolean commitStatus) {
        if (conn == null) {
            return true;
        }/*from ww  w  .j av  a  2s. co  m*/
        try {
            boolean commit = conn.getAutoCommit();
            conn.setAutoCommit(commitStatus);
            return commit;
        } catch (SQLException e1) {
            e1.printStackTrace();
            return true;
        }
    }
}

Related Tutorials