Class TransactionAwareDataSource
java.lang.Object
com.ultikits.ultitools.interfaces.impl.data.TransactionAwareDataSource
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
A
DataSource wrapper that integrates with TransactionManager.
When a transaction is active, returns the transaction's connection wrapped in a
NonClosingConnectionProxy to prevent premature closing by QueryRunner.
When no transaction is active, delegates to the underlying DataSource for normal
auto-commit behavior.
- Since:
- 6.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataSourceprivate final Supplier<TransactionManager> -
Constructor Summary
ConstructorsConstructorDescriptionTransactionAwareDataSource(DataSource delegate, Supplier<TransactionManager> transactionManagerSupplier) -
Method Summary
Modifier and TypeMethodDescriptiongetConnection(String username, String password) intbooleanisWrapperFor(Class<?> iface) voidsetLoginTimeout(int seconds) voidsetLogWriter(PrintWriter out) <T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilderMethods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Field Details
-
delegate
-
transactionManagerSupplier
-
-
Constructor Details
-
TransactionAwareDataSource
TransactionAwareDataSource(DataSource delegate, Supplier<TransactionManager> transactionManagerSupplier)
-
-
Method Details
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getLogWriter
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Throws:
SQLException
-
setLogWriter
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Throws:
SQLException
-
getLoginTimeout
- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
setLoginTimeout
- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-