⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex8_25.txt

📁 j2ee core design patterns
💻 TXT
字号:
Example 8.25 	Transaction Class
import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.transaction.*;

public class Transaction {
	UserTransaction txn;

	public void setSessionContext( SessionContext ctx ) {
		ctx.getUserTransaction();
	}
	public Transaction() {
		InitialContext ic = null;
		try {
			ic = new InitialContext();
			txn = (UserTransaction)ic.lookup(
					"java:comp/UserTransaction");
		} catch (NamingException e) {
		}
	}
	public void begin()
			throws SystemException, NotSupportedException {
		txn.begin();
	}

	public void commit()
			throws SystemException, HeuristicRollbackException,
			RollbackException, HeuristicMixedException {
		txn.commit();
	}

	public void rollback() throws SystemException {
		txn.rollback();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -