public class JDBCTransaction extends Object implements AutoCloseable
Constructor and Description |
---|
JDBCTransaction(Connection connection)
Open a transaction on the given connection using the default
isolation level of the connection.
|
JDBCTransaction(Connection connection,
int isolationLevel)
Open a transaction on the given connection using the given
isolation level.
|
JDBCTransaction(DataSource dataSource)
Pull a connection from the given datasource and open a transaction
with the default isolation level of the datasource.
|
JDBCTransaction(DataSource dataSource,
int isolationLevel)
Pull a connection from the given datasource and open a transaction
with the given isolation level.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Roll back the transaction.
|
void |
commit()
Commit the transaction.
|
protected void |
dropConnection() |
protected static Connection |
fetchConnection(DataSource dataSource) |
Connection |
getConnection() |
boolean |
isOpen() |
void |
rollback()
An alias for
close() . |
protected void |
startTransaction() |
public JDBCTransaction(DataSource dataSource) throws SQLException
close()
.dataSource
- The data source to pull a connection from.SQLException
- Upon errors opening the transaction.public JDBCTransaction(DataSource dataSource, int isolationLevel) throws SQLException
close()
.dataSource
- The data source to pull a connection from.isolationLevel
- The isolation level to use.SQLException
- Upon errors opening the transaction.Connection.TRANSACTION_NONE
,
Connection.TRANSACTION_READ_UNCOMMITTED
,
Connection.TRANSACTION_READ_COMMITTED
,
Connection.TRANSACTION_REPEATABLE_READ
,
Connection.TRANSACTION_SERIALIZABLE
public JDBCTransaction(Connection connection) throws SQLException
close()
.connection
- The JDBC connection to operate on.SQLException
- Upon errors opening the transaction.public JDBCTransaction(Connection connection, int isolationLevel) throws SQLException
close()
.connection
- The JDBC connection to operate on.isolationLevel
- The isolation level to use.SQLException
- Upon errors opening the transaction.Connection.TRANSACTION_NONE
,
Connection.TRANSACTION_READ_UNCOMMITTED
,
Connection.TRANSACTION_READ_COMMITTED
,
Connection.TRANSACTION_REPEATABLE_READ
,
Connection.TRANSACTION_SERIALIZABLE
protected void startTransaction() throws SQLException
SQLException
protected void dropConnection()
protected static Connection fetchConnection(DataSource dataSource) throws SQLException
SQLException
public boolean isOpen()
public Connection getConnection()
null
,
if this transaction has already been rolled back or committed.public void commit() throws SQLException
SQLException
- Upon errors.public void rollback() throws SQLException
close()
.SQLException
- Upon errors rolling back the transaction.public void close() throws SQLException
close
in interface AutoCloseable
SQLException
- Upon errors rolling back the transaction.Copyright © 2017 Clazzes.org. All rights reserved.