public class JdbcTransaction extends Object implements Transaction
Transaction that makes use of the JDBC commit and rollback facilities directly.
It relies on the connection retrieved from the dataSource to manage the scope of the transaction.
Delays connection retrieval until getConnection() is called.
Ignores commit or rollback requests when autocommit is on.JdbcTransactionFactory| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoCommit |
protected Connection |
connection |
protected DataSource |
dataSource |
protected TransactionIsolationLevel |
level |
| Constructor and Description |
|---|
JdbcTransaction(Connection connection) |
JdbcTransaction(DataSource ds,
TransactionIsolationLevel desiredLevel,
boolean desiredAutoCommit) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close inner database connection.
|
void |
commit()
Commit inner database connection.
|
Connection |
getConnection()
Retrieve inner database connection.
|
Integer |
getTimeout()
Get transaction timeout if set.
|
protected void |
openConnection() |
protected void |
resetAutoCommit() |
void |
rollback()
Rollback inner database connection.
|
protected void |
setDesiredAutoCommit(boolean desiredAutoCommit) |
protected Connection connection
protected DataSource dataSource
protected TransactionIsolationLevel level
protected boolean autoCommit
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)
public JdbcTransaction(Connection connection)
public Connection getConnection() throws SQLException
TransactiongetConnection in interface TransactionSQLException - the SQL exceptionpublic void commit()
throws SQLException
Transactioncommit in interface TransactionSQLException - the SQL exceptionpublic void rollback()
throws SQLException
Transactionrollback in interface TransactionSQLException - the SQL exceptionpublic void close()
throws SQLException
Transactionclose in interface TransactionSQLException - the SQL exceptionprotected void setDesiredAutoCommit(boolean desiredAutoCommit)
protected void resetAutoCommit()
protected void openConnection()
throws SQLException
SQLExceptionpublic Integer getTimeout() throws SQLException
TransactiongetTimeout in interface TransactionSQLException - the SQL exceptionCopyright © 2009–2021 MyBatis.org. All rights reserved.