All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibatis.sqlmap.engine.transaction.IsolationLevel Maven / Gradle / Ivy

Go to download

The jBATIS persistence framework will help you to significantly reduce the amount of Java code that you normally need to access a relational database. iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor.

The newest version!
package com.ibatis.sqlmap.engine.transaction;

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

public class IsolationLevel {

    public static final int UNSET_ISOLATION_LEVEL = -9999;

    private int isolationLevel = UNSET_ISOLATION_LEVEL;
    private int originalIsolationLevel = UNSET_ISOLATION_LEVEL;

    public void setIsolationLevel(int isolationLevel) {
        this.isolationLevel = isolationLevel;
    }

    public void applyIsolationLevel(Connection conn) throws SQLException {
        if (isolationLevel != UNSET_ISOLATION_LEVEL) {
            originalIsolationLevel = conn.getTransactionIsolation();
            if (isolationLevel != originalIsolationLevel) {
                conn.setTransactionIsolation(isolationLevel);
            }
        }
    }

    public void restoreIsolationLevel(Connection conn) throws SQLException {
        if (isolationLevel != originalIsolationLevel) {
            conn.setTransactionIsolation(originalIsolationLevel);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy