Class JdbcTransaction
- java.lang.Object
-
- org.apache.ibatis.transaction.jdbc.JdbcTransaction
-
- All Implemented Interfaces:
Transaction
public class JdbcTransaction extends Object implements Transaction
Transactionthat 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.- Author:
- Clinton Begin
- See Also:
JdbcTransactionFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoCommitprotected Connectionconnectionprotected DataSourcedataSourceprotected TransactionIsolationLevellevelprotected booleanskipSetAutoCommitOnClose
-
Constructor Summary
Constructors Constructor Description JdbcTransaction(Connection connection)JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close inner database connection.voidcommit()Commit inner database connection.ConnectiongetConnection()Retrieve inner database connection.IntegergetTimeout()Get transaction timeout if set.protected voidopenConnection()protected voidresetAutoCommit()voidrollback()Rollback inner database connection.protected voidsetDesiredAutoCommit(boolean desiredAutoCommit)
-
-
-
Field Detail
-
connection
protected Connection connection
-
dataSource
protected DataSource dataSource
-
level
protected TransactionIsolationLevel level
-
autoCommit
protected boolean autoCommit
-
skipSetAutoCommitOnClose
protected boolean skipSetAutoCommitOnClose
-
-
Constructor Detail
-
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit)
-
JdbcTransaction
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose)
-
JdbcTransaction
public JdbcTransaction(Connection connection)
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
Description copied from interface:TransactionRetrieve inner database connection.- Specified by:
getConnectionin interfaceTransaction- Returns:
- DataBase connection
- Throws:
SQLException- the SQL exception
-
commit
public void commit() throws SQLExceptionDescription copied from interface:TransactionCommit inner database connection.- Specified by:
commitin interfaceTransaction- Throws:
SQLException- the SQL exception
-
rollback
public void rollback() throws SQLExceptionDescription copied from interface:TransactionRollback inner database connection.- Specified by:
rollbackin interfaceTransaction- Throws:
SQLException- the SQL exception
-
close
public void close() throws SQLExceptionDescription copied from interface:TransactionClose inner database connection.- Specified by:
closein interfaceTransaction- Throws:
SQLException- the SQL exception
-
setDesiredAutoCommit
protected void setDesiredAutoCommit(boolean desiredAutoCommit)
-
resetAutoCommit
protected void resetAutoCommit()
-
openConnection
protected void openConnection() throws SQLException- Throws:
SQLException
-
getTimeout
public Integer getTimeout() throws SQLException
Description copied from interface:TransactionGet transaction timeout if set.- Specified by:
getTimeoutin interfaceTransaction- Returns:
- the timeout
- Throws:
SQLException- the SQL exception
-
-