|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.transaction Interface UserTransaction
public interface UserTransaction
UserTransaction 接口定义帮助应用程序显式管理事务邦定的方法。
The UserTransaction interface defines the methods that allow an application to explicitly manage transaction boundaries.
Method Summary | |
---|---|
void |
begin()
Create a new transaction and associate it with the current thread. |
void |
commit()
Complete the transaction associated with the current thread. |
int |
getStatus()
Obtain the status of the transaction associated with the current thread. |
void |
rollback()
Roll back the transaction associated with the current thread. |
void |
setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction. |
void |
setTransactionTimeout(int seconds)
Modify the timeout value that is associated with transactions started by the current thread with the begin method. |
Method Detail |
---|
public void
begin() throws NotSupportedException, SystemException
创建一个新事务,并将其与当前线程关联。
Throws | NotSupportedException: 如果线程已经与事务关联,但 TransactionManager 实现不支持嵌套的事务。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
begin
void begin() throws NotSupportedException, SystemException
- Create a new transaction and associate it with the current thread.
- Throws:
NotSupportedException
- Thrown if the thread is already associated with a transaction and the Transaction Manager implementation does not support nested transactions.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
完成与当前线程关联的事务。完成此方法时,线程不再与事务关联。
Throws | RollbackException: 抛出该异常指示事务已经回滚,而不是提交。 |
Throws | HeuristicMixedException: 抛出该异常指示做出了启发式决策,提交了一部分相关更新,同时回滚了另一部分。 |
Throws | HeuristicRollbackException: 抛出该异常指示做出了启发式决策,回滚了所有相关更新。 |
Throws | SecurityException: 抛出该异常指示不允许线程提交事务。 |
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
commit
void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException
- Complete the transaction associated with the current thread. When this
method completes, the thread is no longer associated with a transaction.
- Throws:
RollbackException
- Thrown to indicate that the transaction has been rolled back rather than committed.HeuristicMixedException
- Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.HeuristicRollbackException
- Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.SecurityException
- Thrown to indicate that the thread is not allowed to commit the transaction.IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
rollback() throws IllegalStateException, SecurityException, SystemException
回滚与当前线程关联的事务。完成此方法时,线程不再与事务关联。
Throws | SecurityException: 抛出该异常指示不允许线程回滚事务。 |
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
rollback
void rollback() throws IllegalStateException, SecurityException, SystemException
- Roll back the transaction associated with the current thread. When this
method completes, the thread is no longer associated with a transaction.
- Throws:
SecurityException
- Thrown to indicate that the thread is not allowed to roll back the transaction.IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
setRollbackOnly() throws IllegalStateException, SystemException
修改与当前线程关联的事务,从而使事务的唯一可能结果为回滚事务。
Throws | IllegalStateException: 如果当前线程不与事务关联,则抛出该异常。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
setRollbackOnly
void setRollbackOnly() throws IllegalStateException, SystemException
- Modify the transaction associated with the current thread such that
the only possible outcome of the transaction is to roll back the
transaction.
- Throws:
IllegalStateException
- Thrown if the current thread is not associated with a transaction.SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public int
getStatus() throws SystemException
获取与当前线程关联的事务状态。
return | 事务状态。如果没有任何事务与当前线程关联,则此方法返回 Status.NoTransaction 值。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
getStatus
int getStatus() throws SystemException
- Obtain the status of the transaction associated with the current thread.
- Returns:
- The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
- Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
public void
setTransactionTimeout(int seconds) throws SystemException
修改与事务关联的超时值,这些事务由当前线程通过 begin 方法启动。
如果应用程序没有调用此方法,则事务服务对事务超时使用某个默认值。
seconds | 超时值(以秒为单位)。如果值为 0,则事务服务恢复默认值。如果值为负,则抛出 SystemException。 |
Throws | SystemException: 如果事务管理器遇到不可预料的错误情况,则抛出该异常。 |
setTransactionTimeout
void setTransactionTimeout(int seconds) throws SystemException
- Modify the timeout value that is associated with transactions started
by the current thread with the begin method.
If an application has not called this method, the transaction service uses some default value for the transaction timeout.
- Parameters:
seconds
- The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.- Throws:
SystemException
- Thrown if the transaction manager encounters an unexpected error condition.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!