Package org.dellroad.stuff.schema
Class UpdatingDataSource
java.lang.Object
org.dellroad.stuff.schema.AbstractUpdatingDataSource
org.dellroad.stuff.schema.UpdatingDataSource
- All Implemented Interfaces:
Wrapper
,CommonDataSource
,DataSource
A
DataSource
that wraps an inner DataSource
and automatically applies a configured
SQLCommandList
on first access.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
setSQLCommandList
(SQLCommandList action) Configure theSQLCommandList
to be applied to the database on first access.void
setTransactional
(boolean transactional) Configure whether theSQLCommandList
is applied transactionally or not.protected void
updateDataSource
(DataSource dataSource) Update the innerDataSource
.Methods inherited from class org.dellroad.stuff.schema.AbstractUpdatingDataSource
getConnection, getConnection, getInnerDataSource, getLoginTimeout, getLogWriter, getParentLogger, getUpdateCompleteFuture, getUpdatedDataSource, isAsynchronous, isUpdated, isWrapperFor, setAsynchronous, setDataSource, setLoginTimeout, setLogWriter, triggerUpdate, triggerUpdate, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Constructor Details
-
UpdatingDataSource
public UpdatingDataSource()
-
-
Method Details
-
setSQLCommandList
Configure theSQLCommandList
to be applied to the database on first access. Required property.- Parameters:
action
- SQL command(s) to apply exactly once to the underlyingDataSource
-
setTransactional
public void setTransactional(boolean transactional) Configure whether theSQLCommandList
is applied transactionally or not. Default istrue
.- Parameters:
transactional
- true for transactional application of SQL command(s)
-
updateDataSource
Description copied from class:AbstractUpdatingDataSource
Update the innerDataSource
.This method will be invoked at most once.
- Specified by:
updateDataSource
in classAbstractUpdatingDataSource
- Parameters:
dataSource
- theDataSource
to update- Throws:
SQLException
- if the update attempt fails
-