|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | |||||||||
public interface SqlMapTransactionManager
This interface declares methods for demarcating SQL Map transactions.
SqlMapSession,
SqlMapClient| 方法摘要 | |
|---|---|
void |
commitTransaction()
Commits the currently started transaction. |
void |
endTransaction()
Ends a transaction and rolls back if necessary. |
java.sql.Connection |
getCurrentConnection()
Returns the current connection in use. |
javax.sql.DataSource |
getDataSource()
Returns the DataSource instance currently being used by the SqlMapSession. |
java.sql.Connection |
getUserConnection()
Deprecated. Use getCurrentConnection() instead. |
void |
setUserConnection(java.sql.Connection connnection)
Allows the developer to easily use an externally supplied connection when executing statements. |
void |
startTransaction()
Demarcates the beginning of a transaction scope. |
void |
startTransaction(int transactionIsolation)
Demarcates the beginning of a transaction scope using the specified transaction isolation. |
| 方法详细信息 |
|---|
void startTransaction()
throws java.sql.SQLException
try {
sqlMap.startTransaction();
// do work
sqlMap.commitTransaction();
} finally {
sqlMap.endTransaction();
}
Always call endTransaction() once startTransaction() has been called.
java.sql.SQLException - If an error occurs while starting the transaction, or
the transaction could not be started.
void startTransaction(int transactionIsolation)
throws java.sql.SQLException
try {
sqlMap.startTransaction(Connection.TRANSACTION_REPEATABLE_READ);
// do work
sqlMap.commitTransaction();
} finally {
sqlMap.endTransaction();
}
Always call endTransaction() once startTransaction() has been called.
java.sql.SQLException - If an error occurs while starting the transaction, or
the transaction could not be started.
void commitTransaction()
throws java.sql.SQLException
java.sql.SQLException - If an error occurs while committing the transaction, or
the transaction could not be committed.
void endTransaction()
throws java.sql.SQLException
java.sql.SQLException - If an error occurs during rollback or the transaction could
not be ended.
void setUserConnection(java.sql.Connection connnection)
throws java.sql.SQLException
try {
Connection connection = dataSource.getConnection();
sqlMap.setUserConnection(connection);
// do work
connection.commit();
} catch (SQLException e) {
try {
if (connection != null) commit.rollback();
} catch (SQLException ignored) {
// generally ignored
}
throw e; // rethrow the exception
} finally {
try {
if (connection != null) connection.close();
} catch (SQLException ignored) {
// generally ignored
}
}
connnection -
java.sql.SQLException
java.sql.Connection getUserConnection()
throws java.sql.SQLException
java.sql.SQLException
java.sql.Connection getCurrentConnection()
throws java.sql.SQLException
java.sql.SQLExceptionjavax.sql.DataSource getDataSource()
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | |||||||||